@wordpress/edit-site 5.26.0 → 5.27.1

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 (340) hide show
  1. package/CHANGELOG.md +2 -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/tab-panel-layout.js +6 -2
  29. package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
  30. package/build/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
  31. package/build/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
  32. package/build/components/global-styles/font-library-modal/utils/index.js +103 -17
  33. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  34. package/build/components/global-styles/font-library-modal/utils/preview-styles.js +4 -3
  35. package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
  36. package/build/components/global-styles/screen-block.js +10 -0
  37. package/build/components/global-styles/screen-block.js.map +1 -1
  38. package/build/components/global-styles/screen-typography.js +4 -1
  39. package/build/components/global-styles/screen-typography.js.map +1 -1
  40. package/build/components/layout/hooks.js +6 -5
  41. package/build/components/layout/hooks.js.map +1 -1
  42. package/build/components/layout/index.js +19 -28
  43. package/build/components/layout/index.js.map +1 -1
  44. package/build/components/layout/router.js +135 -0
  45. package/build/components/layout/router.js.map +1 -0
  46. package/build/components/page-pages/index.js +92 -69
  47. package/build/components/page-pages/index.js.map +1 -1
  48. package/build/components/page-patterns/dataviews-pattern-actions.js +11 -6
  49. package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
  50. package/build/components/page-patterns/index.js +295 -15
  51. package/build/components/page-patterns/index.js.map +1 -1
  52. package/build/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +51 -23
  53. package/build/components/page-templates-template-parts/actions.js.map +1 -0
  54. package/build/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
  55. package/build/components/page-templates-template-parts/index.js +395 -0
  56. package/build/components/page-templates-template-parts/index.js.map +1 -0
  57. package/build/components/preferences-modal/index.js +9 -134
  58. package/build/components/preferences-modal/index.js.map +1 -1
  59. package/build/components/revisions/index.js +1 -1
  60. package/build/components/revisions/index.js.map +1 -1
  61. package/build/components/save-button/index.js +4 -2
  62. package/build/components/save-button/index.js.map +1 -1
  63. package/build/components/save-panel/index.js +6 -5
  64. package/build/components/save-panel/index.js.map +1 -1
  65. package/build/components/sidebar/index.js +3 -1
  66. package/build/components/sidebar/index.js.map +1 -1
  67. package/build/components/sidebar-dataviews/dataview-item.js +3 -1
  68. package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
  69. package/build/components/sidebar-dataviews/default-views.js +4 -2
  70. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  71. package/build/components/sidebar-dataviews/index.js +2 -2
  72. package/build/components/sidebar-dataviews/index.js.map +1 -1
  73. package/build/components/sidebar-navigation-screen/index.js +8 -7
  74. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  75. package/build/components/sidebar-navigation-screen-pages/index.js +2 -10
  76. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  77. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +26 -3
  78. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
  79. package/build/components/sidebar-navigation-screen-templates/index.js +63 -8
  80. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  81. package/build/components/sidebar-navigation-screen-templates-browse/content.js +76 -0
  82. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
  83. package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
  84. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  85. package/build/components/site-hub/index.js +3 -1
  86. package/build/components/site-hub/index.js.map +1 -1
  87. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -12
  88. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  89. package/build/components/sync-state-with-url/use-sync-path-with-url.js +25 -2
  90. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  91. package/build/hooks/commands/use-edit-mode-commands.js +33 -5
  92. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  93. package/build/hooks/push-changes-to-global-styles/index.js +13 -6
  94. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  95. package/build/hooks/template-part-edit.js +7 -6
  96. package/build/hooks/template-part-edit.js.map +1 -1
  97. package/build/index.js +1 -1
  98. package/build/index.js.map +1 -1
  99. package/build/store/actions.js +11 -29
  100. package/build/store/actions.js.map +1 -1
  101. package/build/store/private-actions.js +85 -1
  102. package/build/store/private-actions.js.map +1 -1
  103. package/build/store/selectors.js +2 -2
  104. package/build/store/selectors.js.map +1 -1
  105. package/build/utils/get-is-list-page.js +1 -1
  106. package/build/utils/get-is-list-page.js.map +1 -1
  107. package/build/utils/use-actual-current-theme.js +32 -0
  108. package/build/utils/use-actual-current-theme.js.map +1 -0
  109. package/build-module/components/actions/index.js +139 -36
  110. package/build-module/components/actions/index.js.map +1 -1
  111. package/build-module/components/editor-canvas-container/index.js +1 -1
  112. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  113. package/build-module/components/global-styles/font-families.js +3 -2
  114. package/build-module/components/global-styles/font-families.js.map +1 -1
  115. package/build-module/components/global-styles/font-family-item.js +4 -5
  116. package/build-module/components/global-styles/font-family-item.js.map +1 -1
  117. package/build-module/components/global-styles/font-library-modal/context.js +82 -42
  118. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  119. package/build-module/components/global-styles/font-library-modal/font-collection.js +49 -22
  120. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  121. package/build-module/components/global-styles/font-library-modal/fonts-grid.js +4 -1
  122. package/build-module/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
  123. package/build-module/components/global-styles/font-library-modal/index.js +4 -4
  124. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  125. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +16 -8
  126. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  127. package/build-module/components/global-styles/font-library-modal/library-font-card.js +1 -1
  128. package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
  129. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  130. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  131. package/build-module/components/global-styles/font-library-modal/local-fonts.js +13 -4
  132. package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  133. package/build-module/components/global-styles/font-library-modal/resolvers.js +45 -18
  134. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  135. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +6 -2
  136. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
  137. package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
  138. package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
  139. package/build-module/components/global-styles/font-library-modal/utils/index.js +99 -16
  140. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  141. package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +4 -3
  142. package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
  143. package/build-module/components/global-styles/screen-block.js +10 -0
  144. package/build-module/components/global-styles/screen-block.js.map +1 -1
  145. package/build-module/components/global-styles/screen-typography.js +4 -1
  146. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  147. package/build-module/components/layout/hooks.js +6 -5
  148. package/build-module/components/layout/hooks.js.map +1 -1
  149. package/build-module/components/layout/index.js +19 -28
  150. package/build-module/components/layout/index.js.map +1 -1
  151. package/build-module/components/layout/router.js +127 -0
  152. package/build-module/components/layout/router.js.map +1 -0
  153. package/build-module/components/page-pages/index.js +91 -70
  154. package/build-module/components/page-pages/index.js.map +1 -1
  155. package/build-module/components/page-patterns/dataviews-pattern-actions.js +11 -6
  156. package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
  157. package/build-module/components/page-patterns/index.js +296 -16
  158. package/build-module/components/page-patterns/index.js.map +1 -1
  159. package/build-module/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +52 -24
  160. package/build-module/components/page-templates-template-parts/actions.js.map +1 -0
  161. package/build-module/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
  162. package/build-module/components/page-templates-template-parts/index.js +385 -0
  163. package/build-module/components/page-templates-template-parts/index.js.map +1 -0
  164. package/build-module/components/preferences-modal/index.js +12 -136
  165. package/build-module/components/preferences-modal/index.js.map +1 -1
  166. package/build-module/components/revisions/index.js +1 -1
  167. package/build-module/components/revisions/index.js.map +1 -1
  168. package/build-module/components/save-button/index.js +4 -2
  169. package/build-module/components/save-button/index.js.map +1 -1
  170. package/build-module/components/save-panel/index.js +7 -6
  171. package/build-module/components/save-panel/index.js.map +1 -1
  172. package/build-module/components/sidebar/index.js +3 -1
  173. package/build-module/components/sidebar/index.js.map +1 -1
  174. package/build-module/components/sidebar-dataviews/dataview-item.js +3 -1
  175. package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
  176. package/build-module/components/sidebar-dataviews/default-views.js +4 -2
  177. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  178. package/build-module/components/sidebar-dataviews/index.js +2 -2
  179. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  180. package/build-module/components/sidebar-navigation-screen/index.js +8 -7
  181. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  182. package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -10
  183. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  184. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +27 -4
  185. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
  186. package/build-module/components/sidebar-navigation-screen-templates/index.js +64 -9
  187. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  188. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +68 -0
  189. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
  190. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
  191. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  192. package/build-module/components/site-hub/index.js +3 -1
  193. package/build-module/components/site-hub/index.js.map +1 -1
  194. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -11
  195. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  196. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +25 -2
  197. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  198. package/build-module/hooks/commands/use-edit-mode-commands.js +33 -5
  199. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  200. package/build-module/hooks/push-changes-to-global-styles/index.js +13 -6
  201. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  202. package/build-module/hooks/template-part-edit.js +7 -6
  203. package/build-module/hooks/template-part-edit.js.map +1 -1
  204. package/build-module/index.js +1 -1
  205. package/build-module/index.js.map +1 -1
  206. package/build-module/store/actions.js +13 -30
  207. package/build-module/store/actions.js.map +1 -1
  208. package/build-module/store/private-actions.js +83 -0
  209. package/build-module/store/private-actions.js.map +1 -1
  210. package/build-module/store/selectors.js +2 -2
  211. package/build-module/store/selectors.js.map +1 -1
  212. package/build-module/utils/get-is-list-page.js +1 -1
  213. package/build-module/utils/get-is-list-page.js.map +1 -1
  214. package/build-module/utils/use-actual-current-theme.js +24 -0
  215. package/build-module/utils/use-actual-current-theme.js.map +1 -0
  216. package/build-style/style-rtl.css +316 -215
  217. package/build-style/style.css +316 -215
  218. package/package.json +42 -42
  219. package/src/components/actions/index.js +236 -84
  220. package/src/components/editor-canvas-container/index.js +1 -1
  221. package/src/components/global-styles/font-families.js +14 -8
  222. package/src/components/global-styles/font-family-item.js +7 -4
  223. package/src/components/global-styles/font-library-modal/context.js +156 -50
  224. package/src/components/global-styles/font-library-modal/font-collection.js +56 -21
  225. package/src/components/global-styles/font-library-modal/fonts-grid.js +6 -2
  226. package/src/components/global-styles/font-library-modal/index.js +4 -4
  227. package/src/components/global-styles/font-library-modal/installed-fonts.js +18 -8
  228. package/src/components/global-styles/font-library-modal/library-font-card.js +2 -1
  229. package/src/components/global-styles/font-library-modal/library-font-variant.js +10 -9
  230. package/src/components/global-styles/font-library-modal/local-fonts.js +14 -4
  231. package/src/components/global-styles/font-library-modal/resolvers.js +50 -17
  232. package/src/components/global-styles/font-library-modal/style.scss +23 -35
  233. package/src/components/global-styles/font-library-modal/tab-panel-layout.js +30 -26
  234. package/src/components/global-styles/font-library-modal/utils/filter-fonts.js +19 -2
  235. package/src/components/global-styles/font-library-modal/utils/index.js +136 -29
  236. package/src/components/global-styles/font-library-modal/utils/preview-styles.js +7 -3
  237. package/src/components/global-styles/font-library-modal/utils/test/filter-fonts.spec.js +40 -10
  238. package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +5 -5
  239. package/src/components/global-styles/screen-block.js +10 -0
  240. package/src/components/global-styles/screen-typography.js +9 -3
  241. package/src/components/global-styles/style.scss +4 -0
  242. package/src/components/header-edit-mode/style.scss +15 -5
  243. package/src/components/layout/hooks.js +6 -5
  244. package/src/components/layout/index.js +80 -96
  245. package/src/components/layout/router.js +121 -0
  246. package/src/components/layout/style.scss +13 -16
  247. package/src/components/page/style.scss +1 -8
  248. package/src/components/page-pages/index.js +142 -148
  249. package/src/components/page-pages/style.scss +41 -2
  250. package/src/components/page-patterns/dataviews-pattern-actions.js +11 -6
  251. package/src/components/page-patterns/index.js +392 -14
  252. package/src/components/page-patterns/style.scss +36 -2
  253. package/src/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +90 -37
  254. package/src/components/{page-templates → page-templates-template-parts}/index.js +198 -169
  255. package/src/components/page-templates-template-parts/style.scss +44 -0
  256. package/src/components/preferences-modal/index.js +8 -211
  257. package/src/components/revisions/index.js +1 -1
  258. package/src/components/save-button/index.js +7 -4
  259. package/src/components/save-panel/index.js +13 -12
  260. package/src/components/sidebar/index.js +4 -5
  261. package/src/components/sidebar-dataviews/dataview-item.js +2 -1
  262. package/src/components/sidebar-dataviews/default-views.js +4 -2
  263. package/src/components/sidebar-dataviews/index.js +8 -6
  264. package/src/components/sidebar-navigation-item/style.scss +1 -1
  265. package/src/components/sidebar-navigation-screen/index.js +19 -10
  266. package/src/components/sidebar-navigation-screen-pages/index.js +2 -10
  267. package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +32 -6
  268. package/src/components/sidebar-navigation-screen-templates/index.js +85 -28
  269. package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
  270. package/src/components/sidebar-navigation-screen-templates-browse/content.js +73 -0
  271. package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -1
  272. package/src/components/site-hub/index.js +4 -1
  273. package/src/components/site-hub/style.scss +1 -12
  274. package/src/components/site-icon/style.scss +1 -1
  275. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +40 -10
  276. package/src/components/sync-state-with-url/use-sync-path-with-url.js +32 -0
  277. package/src/hooks/commands/use-edit-mode-commands.js +50 -3
  278. package/src/hooks/push-changes-to-global-styles/index.js +29 -23
  279. package/src/hooks/template-part-edit.js +12 -12
  280. package/src/index.js +1 -1
  281. package/src/store/actions.js +17 -51
  282. package/src/store/private-actions.js +133 -0
  283. package/src/store/selectors.js +2 -4
  284. package/src/style.scss +2 -1
  285. package/src/utils/get-is-list-page.js +3 -2
  286. package/src/utils/use-actual-current-theme.js +27 -0
  287. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
  288. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
  289. package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -71
  290. package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
  291. package/build/components/page-main/index.js +0 -44
  292. package/build/components/page-main/index.js.map +0 -1
  293. package/build/components/page-patterns/dataviews-patterns.js +0 -307
  294. package/build/components/page-patterns/dataviews-patterns.js.map +0 -1
  295. package/build/components/page-template-parts/add-new-template-part.js.map +0 -1
  296. package/build/components/page-template-parts/index.js +0 -81
  297. package/build/components/page-template-parts/index.js.map +0 -1
  298. package/build/components/page-templates/index.js +0 -352
  299. package/build/components/page-templates/index.js.map +0 -1
  300. package/build/components/page-templates/template-actions.js.map +0 -1
  301. package/build/components/post-preview/index.js +0 -29
  302. package/build/components/post-preview/index.js.map +0 -1
  303. package/build/components/preferences-modal/enable-feature.js +0 -36
  304. package/build/components/preferences-modal/enable-feature.js.map +0 -1
  305. package/build/components/preferences-modal/enable-panel-option.js +0 -33
  306. package/build/components/preferences-modal/enable-panel-option.js.map +0 -1
  307. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -52
  308. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
  309. package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -63
  310. package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
  311. package/build-module/components/page-main/index.js +0 -36
  312. package/build-module/components/page-main/index.js.map +0 -1
  313. package/build-module/components/page-patterns/dataviews-patterns.js +0 -299
  314. package/build-module/components/page-patterns/dataviews-patterns.js.map +0 -1
  315. package/build-module/components/page-template-parts/add-new-template-part.js.map +0 -1
  316. package/build-module/components/page-template-parts/index.js +0 -73
  317. package/build-module/components/page-template-parts/index.js.map +0 -1
  318. package/build-module/components/page-templates/index.js +0 -344
  319. package/build-module/components/page-templates/index.js.map +0 -1
  320. package/build-module/components/page-templates/template-actions.js.map +0 -1
  321. package/build-module/components/post-preview/index.js +0 -21
  322. package/build-module/components/post-preview/index.js.map +0 -1
  323. package/build-module/components/preferences-modal/enable-feature.js +0 -29
  324. package/build-module/components/preferences-modal/enable-feature.js.map +0 -1
  325. package/build-module/components/preferences-modal/enable-panel-option.js +0 -26
  326. package/build-module/components/preferences-modal/enable-panel-option.js.map +0 -1
  327. package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
  328. package/src/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -62
  329. package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +0 -271
  330. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +0 -58
  331. package/src/components/page-main/index.js +0 -38
  332. package/src/components/page-patterns/dataviews-patterns.js +0 -380
  333. package/src/components/page-template-parts/index.js +0 -99
  334. package/src/components/page-templates/style.scss +0 -13
  335. package/src/components/post-preview/index.js +0 -16
  336. package/src/components/preferences-modal/enable-feature.js +0 -31
  337. package/src/components/preferences-modal/enable-panel-option.js +0 -23
  338. /package/build/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
  339. /package/build-module/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
  340. /package/src/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
@@ -18,7 +18,7 @@ function TabPanelLayout({
18
18
  }), createElement(VStack, {
19
19
  spacing: 4,
20
20
  justify: "space-between"
21
- }, createElement("header", null, createElement(VStack, {
21
+ }, createElement(VStack, {
22
22
  spacing: 2
23
23
  }, createElement(HStack, {
24
24
  justify: "flex-start"
@@ -31,7 +31,11 @@ function TabPanelLayout({
31
31
  level: 2,
32
32
  size: 13,
33
33
  className: "edit-site-global-styles-header"
34
- }, title)), description && createElement(Text, null, description))), createElement("main", null, children), footer && createElement("footer", null, footer)));
34
+ }, title)), description && createElement(Text, null, description)), createElement("div", {
35
+ className: "font-library-modal__tabpanel-layout__main"
36
+ }, children), footer && createElement("div", {
37
+ className: "font-library-modal__tabpanel-layout__footer"
38
+ }, footer)));
35
39
  }
36
40
  export default TabPanelLayout;
37
41
  //# sourceMappingURL=tab-panel-layout.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalText","Text","__experimentalHeading","Heading","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHStack","HStack","Button","chevronLeft","TabPanelLayout","title","description","handleBack","children","footer","createElement","className","margin","spacing","justify","variant","onClick","icon","size","level"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalText as Text,\n\t__experimentalHeading as Heading,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHStack as HStack,\n\tButton,\n} from '@wordpress/components';\nimport { chevronLeft } from '@wordpress/icons';\n\nfunction TabPanelLayout( {\n\ttitle,\n\tdescription,\n\thandleBack,\n\tchildren,\n\tfooter,\n} ) {\n\treturn (\n\t\t<div className=\"font-library-modal__tabpanel-layout\">\n\t\t\t<Spacer margin={ 4 } />\n\t\t\t<VStack spacing={ 4 } justify=\"space-between\">\n\t\t\t\t<header>\n\t\t\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t\t\t{ !! handleBack && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ handleBack }\n\t\t\t\t\t\t\t\t\ticon={ chevronLeft }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ description && <Text>{ description }</Text> }\n\t\t\t\t\t</VStack>\n\t\t\t\t</header>\n\t\t\t\t<main>{ children }</main>\n\t\t\t\t{ footer && <footer>{ footer }</footer> }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport default TabPanelLayout;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,kBAAkB,IAAIC,IAAI,EAC1BC,qBAAqB,IAAIC,OAAO,EAChCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,QACA,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,cAAcA,CAAE;EACxBC,KAAK;EACLC,WAAW;EACXC,UAAU;EACVC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,OACCC,aAAA;IAAKC,SAAS,EAAC;EAAqC,GACnDD,aAAA,CAACX,MAAM;IAACa,MAAM,EAAG;EAAG,CAAE,CAAC,EACvBF,aAAA,CAACb,MAAM;IAACgB,OAAO,EAAG,CAAG;IAACC,OAAO,EAAC;EAAe,GAC5CJ,aAAA,iBACCA,aAAA,CAACb,MAAM;IAACgB,OAAO,EAAG;EAAG,GACpBH,aAAA,CAACT,MAAM;IAACa,OAAO,EAAC;EAAY,GACzB,CAAC,CAAEP,UAAU,IACdG,aAAA,CAACR,MAAM;IACNa,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGT,UAAY;IACtBU,IAAI,EAAGd,WAAa;IACpBe,IAAI,EAAC;EAAO,CACZ,CACD,EACCb,KAAK,IACNK,aAAA,CAACf,OAAO;IACPwB,KAAK,EAAG,CAAG;IACXD,IAAI,EAAG,EAAI;IACXP,SAAS,EAAC;EAAgC,GAExCN,KACM,CAEH,CAAC,EACPC,WAAW,IAAII,aAAA,CAACjB,IAAI,QAAGa,WAAmB,CACrC,CACD,CAAC,EACTI,aAAA,eAAQF,QAAgB,CAAC,EACvBC,MAAM,IAAIC,aAAA,iBAAUD,MAAgB,CAC/B,CACJ,CAAC;AAER;AAEA,eAAeL,cAAc"}
1
+ {"version":3,"names":["__experimentalText","Text","__experimentalHeading","Heading","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHStack","HStack","Button","chevronLeft","TabPanelLayout","title","description","handleBack","children","footer","createElement","className","margin","spacing","justify","variant","onClick","icon","size","level"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalText as Text,\n\t__experimentalHeading as Heading,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHStack as HStack,\n\tButton,\n} from '@wordpress/components';\nimport { chevronLeft } from '@wordpress/icons';\n\nfunction TabPanelLayout( {\n\ttitle,\n\tdescription,\n\thandleBack,\n\tchildren,\n\tfooter,\n} ) {\n\treturn (\n\t\t<div className=\"font-library-modal__tabpanel-layout\">\n\t\t\t<Spacer margin={ 4 } />\n\t\t\t<VStack spacing={ 4 } justify=\"space-between\">\n\t\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t\t{ !! handleBack && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ handleBack }\n\t\t\t\t\t\t\t\ticon={ chevronLeft }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t\t{ description && <Text>{ description }</Text> }\n\t\t\t\t</VStack>\n\t\t\t\t<div className=\"font-library-modal__tabpanel-layout__main\">\n\t\t\t\t\t{ children }\n\t\t\t\t</div>\n\t\t\t\t{ footer && (\n\t\t\t\t\t<div className=\"font-library-modal__tabpanel-layout__footer\">\n\t\t\t\t\t\t{ footer }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport default TabPanelLayout;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,kBAAkB,IAAIC,IAAI,EAC1BC,qBAAqB,IAAIC,OAAO,EAChCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,QACA,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,cAAcA,CAAE;EACxBC,KAAK;EACLC,WAAW;EACXC,UAAU;EACVC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,OACCC,aAAA;IAAKC,SAAS,EAAC;EAAqC,GACnDD,aAAA,CAACX,MAAM;IAACa,MAAM,EAAG;EAAG,CAAE,CAAC,EACvBF,aAAA,CAACb,MAAM;IAACgB,OAAO,EAAG,CAAG;IAACC,OAAO,EAAC;EAAe,GAC5CJ,aAAA,CAACb,MAAM;IAACgB,OAAO,EAAG;EAAG,GACpBH,aAAA,CAACT,MAAM;IAACa,OAAO,EAAC;EAAY,GACzB,CAAC,CAAEP,UAAU,IACdG,aAAA,CAACR,MAAM;IACNa,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGT,UAAY;IACtBU,IAAI,EAAGd,WAAa;IACpBe,IAAI,EAAC;EAAO,CACZ,CACD,EACCb,KAAK,IACNK,aAAA,CAACf,OAAO;IACPwB,KAAK,EAAG,CAAG;IACXD,IAAI,EAAG,EAAI;IACXP,SAAS,EAAC;EAAgC,GAExCN,KACM,CAEH,CAAC,EACPC,WAAW,IAAII,aAAA,CAACjB,IAAI,QAAGa,WAAmB,CACrC,CAAC,EACTI,aAAA;IAAKC,SAAS,EAAC;EAA2C,GACvDH,QACE,CAAC,EACJC,MAAM,IACPC,aAAA;IAAKC,SAAS,EAAC;EAA6C,GACzDF,MACE,CAEC,CACJ,CAAC;AAER;AAEA,eAAeL,cAAc"}
@@ -1,3 +1,18 @@
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 {
3
18
  category,
@@ -5,10 +20,10 @@ export default function filterFonts(fonts, filters) {
5
20
  } = filters;
6
21
  let filteredFonts = fonts || [];
7
22
  if (category && category !== 'all') {
8
- filteredFonts = filteredFonts.filter(font => font.category === category);
23
+ filteredFonts = filteredFonts.filter(font => font.categories.indexOf(category) !== -1);
9
24
  }
10
25
  if (search) {
11
- filteredFonts = filteredFonts.filter(font => font.name.toLowerCase().includes(search.toLowerCase()));
26
+ filteredFonts = filteredFonts.filter(font => font.font_family_settings.name.toLowerCase().includes(search.toLowerCase()));
12
27
  }
13
28
  return filteredFonts;
14
29
  }
@@ -1 +1 @@
1
- {"version":3,"names":["filterFonts","fonts","filters","category","search","filteredFonts","filter","font","name","toLowerCase","includes"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/filter-fonts.js"],"sourcesContent":["export default function filterFonts( fonts, filters ) {\n\tconst { category, search } = filters;\n\tlet filteredFonts = fonts || [];\n\n\tif ( category && category !== 'all' ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) => font.category === category\n\t\t);\n\t}\n\n\tif ( search ) {\n\t\tfilteredFonts = filteredFonts.filter( ( font ) =>\n\t\t\tfont.name.toLowerCase().includes( search.toLowerCase() )\n\t\t);\n\t}\n\n\treturn filteredFonts;\n}\n"],"mappings":"AAAA,eAAe,SAASA,WAAWA,CAAEC,KAAK,EAAEC,OAAO,EAAG;EACrD,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGF,OAAO;EACpC,IAAIG,aAAa,GAAGJ,KAAK,IAAI,EAAE;EAE/B,IAAKE,QAAQ,IAAIA,QAAQ,KAAK,KAAK,EAAG;IACrCE,aAAa,GAAGA,aAAa,CAACC,MAAM,CACjCC,IAAI,IAAMA,IAAI,CAACJ,QAAQ,KAAKA,QAC/B,CAAC;EACF;EAEA,IAAKC,MAAM,EAAG;IACbC,aAAa,GAAGA,aAAa,CAACC,MAAM,CAAIC,IAAI,IAC3CA,IAAI,CAACC,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAEN,MAAM,CAACK,WAAW,CAAC,CAAE,CACxD,CAAC;EACF;EAEA,OAAOJ,aAAa;AACrB"}
1
+ {"version":3,"names":["filterFonts","fonts","filters","category","search","filteredFonts","filter","font","categories","indexOf","font_family_settings","name","toLowerCase","includes"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/filter-fonts.js"],"sourcesContent":["/**\n * Filters a list of fonts based on the specified filters.\n *\n * This function filters a given array of fonts based on the criteria provided in the filters object.\n * It supports filtering by category and a search term. If the category is provided and not equal to 'all',\n * the function filters the fonts array to include only those fonts that belong to the specified category.\n * Additionally, if a search term is provided, it filters the fonts array to include only those fonts\n * whose name includes the search term, case-insensitively.\n *\n * @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.\n * @param {Object} filters Object containing the filter criteria. It should have a 'category' key and/or a 'search' key.\n * The 'category' key is a string representing the category to filter by.\n * The 'search' key is a string representing the search term to filter by.\n * @return {Array} Array of filtered font objects based on the provided criteria.\n */\nexport default function filterFonts( fonts, filters ) {\n\tconst { category, search } = filters;\n\tlet filteredFonts = fonts || [];\n\n\tif ( category && category !== 'all' ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) => font.categories.indexOf( category ) !== -1\n\t\t);\n\t}\n\n\tif ( search ) {\n\t\tfilteredFonts = filteredFonts.filter( ( font ) =>\n\t\t\tfont.font_family_settings.name\n\t\t\t\t.toLowerCase()\n\t\t\t\t.includes( search.toLowerCase() )\n\t\t);\n\t}\n\n\treturn filteredFonts;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,WAAWA,CAAEC,KAAK,EAAEC,OAAO,EAAG;EACrD,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGF,OAAO;EACpC,IAAIG,aAAa,GAAGJ,KAAK,IAAI,EAAE;EAE/B,IAAKE,QAAQ,IAAIA,QAAQ,KAAK,KAAK,EAAG;IACrCE,aAAa,GAAGA,aAAa,CAACC,MAAM,CACjCC,IAAI,IAAMA,IAAI,CAACC,UAAU,CAACC,OAAO,CAAEN,QAAS,CAAC,KAAK,CAAC,CACtD,CAAC;EACF;EAEA,IAAKC,MAAM,EAAG;IACbC,aAAa,GAAGA,aAAa,CAACC,MAAM,CAAIC,IAAI,IAC3CA,IAAI,CAACG,oBAAoB,CAACC,IAAI,CAC5BC,WAAW,CAAC,CAAC,CACbC,QAAQ,CAAET,MAAM,CAACQ,WAAW,CAAC,CAAE,CAClC,CAAC;EACF;EAEA,OAAOP,aAAa;AACrB"}
@@ -8,6 +8,15 @@ 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 {
18
+ File
19
+ } = window;
11
20
  export function setUIValuesNeeded(font, extraValues = {}) {
12
21
  if (!font.name && (font.fontFamily || font.slug)) {
13
22
  font.name = font.fontFamily || font.slug;
@@ -82,10 +91,10 @@ export async function loadFontFaceInBrowser(fontFace, source, addTo = 'all') {
82
91
  // eslint-disable-next-line no-undef
83
92
  } else if (source instanceof File) {
84
93
  dataSource = await source.arrayBuffer();
94
+ } else {
95
+ return;
85
96
  }
86
-
87
- // eslint-disable-next-line no-undef
88
- const newFont = new FontFace(fontFace.fontFamily, dataSource, {
97
+ const newFont = new window.FontFace(formatFontFamily(fontFace.fontFamily), dataSource, {
89
98
  style: fontFace.fontStyle,
90
99
  weight: fontFace.fontWeight
91
100
  });
@@ -117,38 +126,112 @@ export function getDisplaySrcFromFontFace(input, urlPrefix) {
117
126
  }
118
127
  return src;
119
128
  }
120
- export function makeFormDataFromFontFamily(fontFamily) {
129
+ export function makeFontFamilyFormData(fontFamily) {
121
130
  const formData = new FormData();
122
131
  const {
123
132
  kebabCase
124
133
  } = unlock(componentsPrivateApis);
125
- const newFontFamily = {
126
- ...fontFamily,
134
+ const {
135
+ fontFace,
136
+ category,
137
+ ...familyWithValidParameters
138
+ } = fontFamily;
139
+ const fontFamilySettings = {
140
+ ...familyWithValidParameters,
127
141
  slug: kebabCase(fontFamily.slug)
128
142
  };
129
- if (newFontFamily?.fontFace) {
130
- const newFontFaces = newFontFamily.fontFace.map((face, faceIndex) => {
143
+ formData.append('font_family_settings', JSON.stringify(fontFamilySettings));
144
+ return formData;
145
+ }
146
+ export function makeFontFacesFormData(font) {
147
+ if (font?.fontFace) {
148
+ const fontFacesFormData = font.fontFace.map((face, faceIndex) => {
149
+ const formData = new FormData();
131
150
  if (face.file) {
132
151
  // Slugified file name because the it might contain spaces or characters treated differently on the server.
133
152
  const fileId = `file-${faceIndex}`;
134
153
  // Add the files to the formData
135
154
  formData.append(fileId, face.file, face.file.name);
136
- // remove the file object from the face object the file is referenced by the uploadedFile key
155
+ // remove the file object from the face object the file is referenced in src
137
156
  const {
138
157
  file,
139
158
  ...faceWithoutFileProperty
140
159
  } = face;
141
- const newFace = {
160
+ const fontFaceSettings = {
142
161
  ...faceWithoutFileProperty,
143
- uploadedFile: fileId
162
+ src: fileId
144
163
  };
145
- return newFace;
164
+ formData.append('font_face_settings', JSON.stringify(fontFaceSettings));
165
+ } else {
166
+ formData.append('font_face_settings', JSON.stringify(face));
146
167
  }
147
- return face;
168
+ return formData;
148
169
  });
149
- newFontFamily.fontFace = newFontFaces;
170
+ return fontFacesFormData;
150
171
  }
151
- formData.append('font_family_settings', JSON.stringify(newFontFamily));
152
- return formData;
172
+ }
173
+ export async function batchInstallFontFaces(fontFamilyId, fontFacesData) {
174
+ const promises = fontFacesData.map(faceData => fetchInstallFontFace(fontFamilyId, faceData));
175
+ const responses = await Promise.allSettled(promises);
176
+ const results = {
177
+ errors: [],
178
+ successes: []
179
+ };
180
+ responses.forEach((result, index) => {
181
+ if (result.status === 'fulfilled') {
182
+ const response = result.value;
183
+ if (response.id) {
184
+ results.successes.push(response);
185
+ } else {
186
+ results.errors.push({
187
+ data: fontFacesData[index],
188
+ message: `Error: ${response.message}`
189
+ });
190
+ }
191
+ } else {
192
+ // Handle network errors or other fetch-related errors
193
+ results.errors.push({
194
+ data: fontFacesData[index],
195
+ message: `Fetch error: ${result.reason.message}`
196
+ });
197
+ }
198
+ });
199
+ return results;
200
+ }
201
+
202
+ /*
203
+ * Downloads a font face asset from a URL to the client and returns a File object.
204
+ */
205
+ export async function downloadFontFaceAsset(url) {
206
+ return fetch(new Request(url)).then(response => {
207
+ if (!response.ok) {
208
+ throw new Error(`Error downloading font face asset from ${url}. Server responded with status: ${response.status}`);
209
+ }
210
+ return response.blob();
211
+ }).then(blob => {
212
+ const filename = url.split('/').pop();
213
+ const file = new File([blob], filename, {
214
+ type: blob.type
215
+ });
216
+ return file;
217
+ }).catch(error => {
218
+ // eslint-disable-next-line no-console
219
+ console.error(`Error downloading font face asset from ${url}:`, error);
220
+ throw error;
221
+ });
222
+ }
223
+
224
+ /*
225
+ * Determine if a given Font Face is present in a given collection.
226
+ * We determine that a font face has been installed by comparing the fontWeight and fontStyle
227
+ *
228
+ * @param {Object} fontFace The Font Face to seek
229
+ * @param {Array} collection The Collection to seek in
230
+ * @returns True if the font face is found in the collection. Otherwise False.
231
+ */
232
+ export function checkFontFaceInstalled(fontFace, collection) {
233
+ return -1 !== collection.findIndex(collectionFontFace => {
234
+ return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle;
235
+ });
153
236
  }
154
237
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["privateApis","componentsPrivateApis","FONT_WEIGHTS","FONT_STYLES","unlock","setUIValuesNeeded","font","extraValues","name","fontFamily","slug","isUrlEncoded","url","decodeURIComponent","getFontFaceVariantName","face","weightName","fontWeight","styleName","fontStyle","mergeFontFaces","existing","incoming","map","Map","set","Array","from","values","mergeFontFamilies","has","fontFace","incomingFontFaces","restIncoming","existingFont","get","mergedFontFaces","loadFontFaceInBrowser","source","addTo","dataSource","File","arrayBuffer","newFont","FontFace","style","weight","loadedFace","load","document","fonts","add","iframeDocument","querySelector","contentDocument","getDisplaySrcFromFontFace","input","urlPrefix","src","isArray","startsWith","replace","encodeURI","makeFormDataFromFontFamily","formData","FormData","kebabCase","newFontFamily","newFontFaces","faceIndex","file","fileId","append","faceWithoutFileProperty","newFace","uploadedFile","JSON","stringify"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { FONT_WEIGHTS, FONT_STYLES } from './constants';\nimport { unlock } from '../../../../lock-unlock';\n\nexport function setUIValuesNeeded( font, extraValues = {} ) {\n\tif ( ! font.name && ( font.fontFamily || font.slug ) ) {\n\t\tfont.name = font.fontFamily || font.slug;\n\t}\n\treturn {\n\t\t...font,\n\t\t...extraValues,\n\t};\n}\n\nexport function isUrlEncoded( url ) {\n\tif ( typeof url !== 'string' ) {\n\t\treturn false;\n\t}\n\treturn url !== decodeURIComponent( url );\n}\n\nexport function getFontFaceVariantName( face ) {\n\tconst weightName = FONT_WEIGHTS[ face.fontWeight ] || face.fontWeight;\n\tconst styleName =\n\t\tface.fontStyle === 'normal'\n\t\t\t? ''\n\t\t\t: FONT_STYLES[ face.fontStyle ] || face.fontStyle;\n\treturn `${ weightName } ${ styleName }`;\n}\n\nexport function mergeFontFaces( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\tfor ( const face of existing ) {\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\tfor ( const face of incoming ) {\n\t\t// This will overwrite if the src already exists, keeping it unique.\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\treturn Array.from( map.values() );\n}\n\nexport function mergeFontFamilies( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\t// Add the existing array to the map.\n\tfor ( const font of existing ) {\n\t\tmap.set( font.slug, { ...font } );\n\t}\n\t// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.\n\tfor ( const font of incoming ) {\n\t\tif ( map.has( font.slug ) ) {\n\t\t\tconst { fontFace: incomingFontFaces, ...restIncoming } = font;\n\t\t\tconst existingFont = map.get( font.slug );\n\t\t\t// Merge the fontFaces existing with the incoming fontFaces.\n\t\t\tconst mergedFontFaces = mergeFontFaces(\n\t\t\t\texistingFont.fontFace,\n\t\t\t\tincomingFontFaces\n\t\t\t);\n\t\t\t// Except for the fontFace key all the other keys are overwritten with the incoming values.\n\t\t\tmap.set( font.slug, {\n\t\t\t\t...restIncoming,\n\t\t\t\tfontFace: mergedFontFaces,\n\t\t\t} );\n\t\t} else {\n\t\t\tmap.set( font.slug, { ...font } );\n\t\t}\n\t}\n\treturn Array.from( map.values() );\n}\n\n/*\n * Loads the font face from a URL and adds it to the browser.\n * It also adds it to the iframe document.\n */\nexport async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {\n\tlet dataSource;\n\n\tif ( typeof source === 'string' ) {\n\t\tdataSource = `url(${ source })`;\n\t\t// eslint-disable-next-line no-undef\n\t} else if ( source instanceof File ) {\n\t\tdataSource = await source.arrayBuffer();\n\t}\n\n\t// eslint-disable-next-line no-undef\n\tconst newFont = new FontFace( fontFace.fontFamily, dataSource, {\n\t\tstyle: fontFace.fontStyle,\n\t\tweight: fontFace.fontWeight,\n\t} );\n\n\tconst loadedFace = await newFont.load();\n\n\tif ( addTo === 'document' || addTo === 'all' ) {\n\t\tdocument.fonts.add( loadedFace );\n\t}\n\n\tif ( addTo === 'iframe' || addTo === 'all' ) {\n\t\tconst iframeDocument = document.querySelector(\n\t\t\t'iframe[name=\"editor-canvas\"]'\n\t\t).contentDocument;\n\t\tiframeDocument.fonts.add( loadedFace );\n\t}\n}\n\nexport function getDisplaySrcFromFontFace( input, urlPrefix ) {\n\tif ( ! input ) {\n\t\treturn;\n\t}\n\n\tlet src;\n\tif ( Array.isArray( input ) ) {\n\t\tsrc = input[ 0 ];\n\t} else {\n\t\tsrc = input;\n\t}\n\t// If it is a theme font, we need to make the url absolute\n\tif ( src.startsWith( 'file:.' ) && urlPrefix ) {\n\t\tsrc = src.replace( 'file:.', urlPrefix );\n\t}\n\tif ( ! isUrlEncoded( src ) ) {\n\t\tsrc = encodeURI( src );\n\t}\n\treturn src;\n}\n\nexport function makeFormDataFromFontFamily( fontFamily ) {\n\tconst formData = new FormData();\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\n\tconst newFontFamily = {\n\t\t...fontFamily,\n\t\tslug: kebabCase( fontFamily.slug ),\n\t};\n\n\tif ( newFontFamily?.fontFace ) {\n\t\tconst newFontFaces = newFontFamily.fontFace.map(\n\t\t\t( face, faceIndex ) => {\n\t\t\t\tif ( face.file ) {\n\t\t\t\t\t// Slugified file name because the it might contain spaces or characters treated differently on the server.\n\t\t\t\t\tconst fileId = `file-${ faceIndex }`;\n\t\t\t\t\t// Add the files to the formData\n\t\t\t\t\tformData.append( fileId, face.file, face.file.name );\n\t\t\t\t\t// remove the file object from the face object the file is referenced by the uploadedFile key\n\t\t\t\t\tconst { file, ...faceWithoutFileProperty } = face;\n\t\t\t\t\tconst newFace = {\n\t\t\t\t\t\t...faceWithoutFileProperty,\n\t\t\t\t\t\tuploadedFile: fileId,\n\t\t\t\t\t};\n\t\t\t\t\treturn newFace;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t\t}\n\t\t);\n\t\tnewFontFamily.fontFace = newFontFaces;\n\t}\n\n\tformData.append( 'font_family_settings', JSON.stringify( newFontFamily ) );\n\treturn formData;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,YAAY,EAAEC,WAAW,QAAQ,aAAa;AACvD,SAASC,MAAM,QAAQ,yBAAyB;AAEhD,OAAO,SAASC,iBAAiBA,CAAEC,IAAI,EAAEC,WAAW,GAAG,CAAC,CAAC,EAAG;EAC3D,IAAK,CAAED,IAAI,CAACE,IAAI,KAAMF,IAAI,CAACG,UAAU,IAAIH,IAAI,CAACI,IAAI,CAAE,EAAG;IACtDJ,IAAI,CAACE,IAAI,GAAGF,IAAI,CAACG,UAAU,IAAIH,IAAI,CAACI,IAAI;EACzC;EACA,OAAO;IACN,GAAGJ,IAAI;IACP,GAAGC;EACJ,CAAC;AACF;AAEA,OAAO,SAASI,YAAYA,CAAEC,GAAG,EAAG;EACnC,IAAK,OAAOA,GAAG,KAAK,QAAQ,EAAG;IAC9B,OAAO,KAAK;EACb;EACA,OAAOA,GAAG,KAAKC,kBAAkB,CAAED,GAAI,CAAC;AACzC;AAEA,OAAO,SAASE,sBAAsBA,CAAEC,IAAI,EAAG;EAC9C,MAAMC,UAAU,GAAGd,YAAY,CAAEa,IAAI,CAACE,UAAU,CAAE,IAAIF,IAAI,CAACE,UAAU;EACrE,MAAMC,SAAS,GACdH,IAAI,CAACI,SAAS,KAAK,QAAQ,GACxB,EAAE,GACFhB,WAAW,CAAEY,IAAI,CAACI,SAAS,CAAE,IAAI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AK,CAAC;QACpD;QACA,MAAM;UAAE8D,IAAI;UAAE,GAAGG;QAAwB,CAAC,GAAG1D,IAAI;QACjD,MAAM2D,OAAO,GAAG;UACf,GAAGD,uBAAuB;UAC1BE,YAAY,EAAEJ;QACf,CAAC;QACD,OAAOG,OAAO;MACf;MACA,OAAO3D,IAAI;IACZ,CACD,CAAC;IACDoD,aAAa,CAACpC,QAAQ,GAAGqC,YAAY;EACtC;EAEAJ,QAAQ,CAACQ,MAAM,CAAE,sBAAsB,EAAEI,IAAI,CAACC,SAAS,CAAEV,aAAc,CAAE,CAAC;EAC1E,OAAOH,QAAQ;AAChB"}
1
+ {"version":3,"names":["privateApis","componentsPrivateApis","FONT_WEIGHTS","FONT_STYLES","unlock","fetchInstallFontFace","formatFontFamily","File","window","setUIValuesNeeded","font","extraValues","name","fontFamily","slug","isUrlEncoded","url","decodeURIComponent","getFontFaceVariantName","face","weightName","fontWeight","styleName","fontStyle","mergeFontFaces","existing","incoming","map","Map","set","Array","from","values","mergeFontFamilies","has","fontFace","incomingFontFaces","restIncoming","existingFont","get","mergedFontFaces","loadFontFaceInBrowser","source","addTo","dataSource","arrayBuffer","newFont","FontFace","style","weight","loadedFace","load","document","fonts","add","iframeDocument","querySelector","contentDocument","getDisplaySrcFromFontFace","input","urlPrefix","src","isArray","startsWith","replace","encodeURI","makeFontFamilyFormData","formData","FormData","kebabCase","category","familyWithValidParameters","fontFamilySettings","append","JSON","stringify","makeFontFacesFormData","fontFacesFormData","faceIndex","file","fileId","faceWithoutFileProperty","fontFaceSettings","batchInstallFontFaces","fontFamilyId","fontFacesData","promises","faceData","responses","Promise","allSettled","results","errors","successes","forEach","result","index","status","response","value","id","push","data","message","reason","downloadFontFaceAsset","fetch","Request","then","ok","Error","blob","filename","split","pop","type","catch","error","console","checkFontFaceInstalled","collection","findIndex","collectionFontFace"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { FONT_WEIGHTS, FONT_STYLES } from './constants';\nimport { unlock } from '../../../../lock-unlock';\nimport { fetchInstallFontFace } from '../resolvers';\nimport { formatFontFamily } from './preview-styles';\n\n/**\n * Browser dependencies\n */\nconst { File } = window;\n\nexport function setUIValuesNeeded( font, extraValues = {} ) {\n\tif ( ! font.name && ( font.fontFamily || font.slug ) ) {\n\t\tfont.name = font.fontFamily || font.slug;\n\t}\n\treturn {\n\t\t...font,\n\t\t...extraValues,\n\t};\n}\n\nexport function isUrlEncoded( url ) {\n\tif ( typeof url !== 'string' ) {\n\t\treturn false;\n\t}\n\treturn url !== decodeURIComponent( url );\n}\n\nexport function getFontFaceVariantName( face ) {\n\tconst weightName = FONT_WEIGHTS[ face.fontWeight ] || face.fontWeight;\n\tconst styleName =\n\t\tface.fontStyle === 'normal'\n\t\t\t? ''\n\t\t\t: FONT_STYLES[ face.fontStyle ] || face.fontStyle;\n\treturn `${ weightName } ${ styleName }`;\n}\n\nexport function mergeFontFaces( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\tfor ( const face of existing ) {\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\tfor ( const face of incoming ) {\n\t\t// This will overwrite if the src already exists, keeping it unique.\n\t\tmap.set( `${ face.fontWeight }${ face.fontStyle }`, face );\n\t}\n\treturn Array.from( map.values() );\n}\n\nexport function mergeFontFamilies( existing = [], incoming = [] ) {\n\tconst map = new Map();\n\t// Add the existing array to the map.\n\tfor ( const font of existing ) {\n\t\tmap.set( font.slug, { ...font } );\n\t}\n\t// Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged.\n\tfor ( const font of incoming ) {\n\t\tif ( map.has( font.slug ) ) {\n\t\t\tconst { fontFace: incomingFontFaces, ...restIncoming } = font;\n\t\t\tconst existingFont = map.get( font.slug );\n\t\t\t// Merge the fontFaces existing with the incoming fontFaces.\n\t\t\tconst mergedFontFaces = mergeFontFaces(\n\t\t\t\texistingFont.fontFace,\n\t\t\t\tincomingFontFaces\n\t\t\t);\n\t\t\t// Except for the fontFace key all the other keys are overwritten with the incoming values.\n\t\t\tmap.set( font.slug, {\n\t\t\t\t...restIncoming,\n\t\t\t\tfontFace: mergedFontFaces,\n\t\t\t} );\n\t\t} else {\n\t\t\tmap.set( font.slug, { ...font } );\n\t\t}\n\t}\n\treturn Array.from( map.values() );\n}\n\n/*\n * Loads the font face from a URL and adds it to the browser.\n * It also adds it to the iframe document.\n */\nexport async function loadFontFaceInBrowser( fontFace, source, addTo = 'all' ) {\n\tlet dataSource;\n\n\tif ( typeof source === 'string' ) {\n\t\tdataSource = `url(${ source })`;\n\t\t// eslint-disable-next-line no-undef\n\t} else if ( source instanceof File ) {\n\t\tdataSource = await source.arrayBuffer();\n\t} else {\n\t\treturn;\n\t}\n\n\tconst newFont = new window.FontFace(\n\t\tformatFontFamily( fontFace.fontFamily ),\n\t\tdataSource,\n\t\t{\n\t\t\tstyle: fontFace.fontStyle,\n\t\t\tweight: fontFace.fontWeight,\n\t\t}\n\t);\n\n\tconst loadedFace = await newFont.load();\n\n\tif ( addTo === 'document' || addTo === 'all' ) {\n\t\tdocument.fonts.add( loadedFace );\n\t}\n\n\tif ( addTo === 'iframe' || addTo === 'all' ) {\n\t\tconst iframeDocument = document.querySelector(\n\t\t\t'iframe[name=\"editor-canvas\"]'\n\t\t).contentDocument;\n\t\tiframeDocument.fonts.add( loadedFace );\n\t}\n}\n\nexport function getDisplaySrcFromFontFace( input, urlPrefix ) {\n\tif ( ! input ) {\n\t\treturn;\n\t}\n\n\tlet src;\n\tif ( Array.isArray( input ) ) {\n\t\tsrc = input[ 0 ];\n\t} else {\n\t\tsrc = input;\n\t}\n\t// If it is a theme font, we need to make the url absolute\n\tif ( src.startsWith( 'file:.' ) && urlPrefix ) {\n\t\tsrc = src.replace( 'file:.', urlPrefix );\n\t}\n\tif ( ! isUrlEncoded( src ) ) {\n\t\tsrc = encodeURI( src );\n\t}\n\treturn src;\n}\n\nexport function makeFontFamilyFormData( fontFamily ) {\n\tconst formData = new FormData();\n\tconst { kebabCase } = unlock( componentsPrivateApis );\n\n\tconst { fontFace, category, ...familyWithValidParameters } = fontFamily;\n\tconst fontFamilySettings = {\n\t\t...familyWithValidParameters,\n\t\tslug: kebabCase( fontFamily.slug ),\n\t};\n\n\tformData.append(\n\t\t'font_family_settings',\n\t\tJSON.stringify( fontFamilySettings )\n\t);\n\treturn formData;\n}\n\nexport function makeFontFacesFormData( font ) {\n\tif ( font?.fontFace ) {\n\t\tconst fontFacesFormData = font.fontFace.map( ( face, faceIndex ) => {\n\t\t\tconst formData = new FormData();\n\t\t\tif ( face.file ) {\n\t\t\t\t// Slugified file name because the it might contain spaces or characters treated differently on the server.\n\t\t\t\tconst fileId = `file-${ faceIndex }`;\n\t\t\t\t// Add the files to the formData\n\t\t\t\tformData.append( fileId, face.file, face.file.name );\n\t\t\t\t// remove the file object from the face object the file is referenced in src\n\t\t\t\tconst { file, ...faceWithoutFileProperty } = face;\n\t\t\t\tconst fontFaceSettings = {\n\t\t\t\t\t...faceWithoutFileProperty,\n\t\t\t\t\tsrc: fileId,\n\t\t\t\t};\n\t\t\t\tformData.append(\n\t\t\t\t\t'font_face_settings',\n\t\t\t\t\tJSON.stringify( fontFaceSettings )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tformData.append( 'font_face_settings', JSON.stringify( face ) );\n\t\t\t}\n\t\t\treturn formData;\n\t\t} );\n\n\t\treturn fontFacesFormData;\n\t}\n}\n\nexport async function batchInstallFontFaces( fontFamilyId, fontFacesData ) {\n\tconst promises = fontFacesData.map( ( faceData ) =>\n\t\tfetchInstallFontFace( fontFamilyId, faceData )\n\t);\n\tconst responses = await Promise.allSettled( promises );\n\n\tconst results = {\n\t\terrors: [],\n\t\tsuccesses: [],\n\t};\n\n\tresponses.forEach( ( result, index ) => {\n\t\tif ( result.status === 'fulfilled' ) {\n\t\t\tconst response = result.value;\n\t\t\tif ( response.id ) {\n\t\t\t\tresults.successes.push( response );\n\t\t\t} else {\n\t\t\t\tresults.errors.push( {\n\t\t\t\t\tdata: fontFacesData[ index ],\n\t\t\t\t\tmessage: `Error: ${ response.message }`,\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Handle network errors or other fetch-related errors\n\t\t\tresults.errors.push( {\n\t\t\t\tdata: fontFacesData[ index ],\n\t\t\t\tmessage: `Fetch error: ${ result.reason.message }`,\n\t\t\t} );\n\t\t}\n\t} );\n\n\treturn results;\n}\n\n/*\n * Downloads a font face asset from a URL to the client and returns a File object.\n */\nexport async function downloadFontFaceAsset( url ) {\n\treturn fetch( new Request( url ) )\n\t\t.then( ( response ) => {\n\t\t\tif ( ! response.ok ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Error downloading font face asset from ${ url }. Server responded with status: ${ response.status }`\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn response.blob();\n\t\t} )\n\t\t.then( ( blob ) => {\n\t\t\tconst filename = url.split( '/' ).pop();\n\t\t\tconst file = new File( [ blob ], filename, {\n\t\t\t\ttype: blob.type,\n\t\t\t} );\n\t\t\treturn file;\n\t\t} )\n\t\t.catch( ( error ) => {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`Error downloading font face asset from ${ url }:`,\n\t\t\t\terror\n\t\t\t);\n\t\t\tthrow error;\n\t\t} );\n}\n\n/*\n * Determine if a given Font Face is present in a given collection.\n * We determine that a font face has been installed by comparing the fontWeight and fontStyle\n *\n * @param {Object} fontFace The Font Face to seek\n * @param {Array} collection The Collection to seek in\n * @returns True if the font face is found in the collection. Otherwise False.\n */\nexport function checkFontFaceInstalled( fontFace, collection ) {\n\treturn (\n\t\t-1 !==\n\t\tcollection.findIndex( ( collectionFontFace ) => {\n\t\t\treturn (\n\t\t\t\tcollectionFontFace.fontWeight === fontFace.fontWeight &&\n\t\t\t\tcollectionFontFace.fontStyle === fontFace.fontStyle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,CAAE,CAAC;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,sBAAsBA,CAAEpF,QAAQ,EAAEqF,UAAU,EAAG;EAC9D,OACC,CAAC,CAAC,KACFA,UAAU,CAACC,SAAS,CAAIC,kBAAkB,IAAM;IAC/C,OACCA,kBAAkB,CAACrG,UAAU,KAAKc,QAAQ,CAACd,UAAU,IACrDqG,kBAAkB,CAACnG,SAAS,KAAKY,QAAQ,CAACZ,SAAS;EAErD,CAAE,CAAC;AAEL"}
@@ -27,9 +27,10 @@ function extractFontWeights(fontFaces) {
27
27
  export function formatFontFamily(input) {
28
28
  return input.split(',').map(font => {
29
29
  font = font.trim(); // Remove any leading or trailing white spaces
30
- // If the font doesn't have single quotes and contains a space, then add single quotes around it
31
- if (!font.startsWith("'") && font.indexOf(' ') !== -1) {
32
- return `'${font}'`;
30
+ // If the font doesn't start with quotes and contains a space, then wrap in quotes.
31
+ // Check that string starts with a single or double quote and not a space
32
+ if (!(font.startsWith('"') || font.startsWith("'")) && font.indexOf(' ') !== -1) {
33
+ return `"${font}"`;
33
34
  }
34
35
  return font; // Return font as is if no transformation is needed
35
36
  }).join(', ');
@@ -1 +1 @@
1
- {"version":3,"names":["findNearest","input","numbers","length","sort","a","b","Math","abs","extractFontWeights","fontFaces","result","forEach","face","weights","String","fontWeight","split","start","parseInt","end","i","push","formatFontFamily","map","font","trim","startsWith","indexOf","join","getFamilyPreviewStyle","family","style","fontFamily","Array","isArray","fontFace","fontStyle","normalFaces","filter","toLowerCase","normalWeights","nearestWeight","getFacePreviewStyle"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/preview-styles.js"],"sourcesContent":["function findNearest( input, numbers ) {\n\t// If the numbers array is empty, return null\n\tif ( numbers.length === 0 ) {\n\t\treturn null;\n\t}\n\t// Sort the array based on the absolute difference with the input\n\tnumbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );\n\t// Return the first element (which will be the nearest) from the sorted array\n\treturn numbers[ 0 ];\n}\n\nfunction extractFontWeights( fontFaces ) {\n\tconst result = [];\n\n\tfontFaces.forEach( ( face ) => {\n\t\tconst weights = String( face.fontWeight ).split( ' ' );\n\n\t\tif ( weights.length === 2 ) {\n\t\t\tconst start = parseInt( weights[ 0 ] );\n\t\t\tconst end = parseInt( weights[ 1 ] );\n\n\t\t\tfor ( let i = start; i <= end; i += 100 ) {\n\t\t\t\tresult.push( i );\n\t\t\t}\n\t\t} else if ( weights.length === 1 ) {\n\t\t\tresult.push( parseInt( weights[ 0 ] ) );\n\t\t}\n\t} );\n\n\treturn result;\n}\n\nexport function formatFontFamily( input ) {\n\treturn input\n\t\t.split( ',' )\n\t\t.map( ( font ) => {\n\t\t\tfont = font.trim(); // Remove any leading or trailing white spaces\n\t\t\t// If the font doesn't have single quotes and contains a space, then add single quotes around it\n\t\t\tif ( ! font.startsWith( \"'\" ) && font.indexOf( ' ' ) !== -1 ) {\n\t\t\t\treturn `'${ font }'`;\n\t\t\t}\n\t\t\treturn font; // Return font as is if no transformation is needed\n\t\t} )\n\t\t.join( ', ' );\n}\n\nexport function getFamilyPreviewStyle( family ) {\n\tconst style = { fontFamily: formatFontFamily( family.fontFamily ) };\n\n\tif ( ! Array.isArray( family.fontFace ) ) {\n\t\tstyle.fontWeight = '400';\n\t\tstyle.fontStyle = 'normal';\n\t\treturn style;\n\t}\n\n\tif ( family.fontFace ) {\n\t\t//get all the font faces with normal style\n\t\tconst normalFaces = family.fontFace.filter(\n\t\t\t( face ) => face.fontStyle.toLowerCase() === 'normal'\n\t\t);\n\t\tif ( normalFaces.length > 0 ) {\n\t\t\tstyle.fontStyle = 'normal';\n\t\t\tconst normalWeights = extractFontWeights( normalFaces );\n\t\t\tconst nearestWeight = findNearest( 400, normalWeights );\n\t\t\tstyle.fontWeight = String( nearestWeight ) || '400';\n\t\t} else {\n\t\t\tstyle.fontStyle =\n\t\t\t\t( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||\n\t\t\t\t'normal';\n\t\t\tstyle.fontWeight =\n\t\t\t\t( family.fontFace.length &&\n\t\t\t\t\tString( family.fontFace[ 0 ].fontWeight ) ) ||\n\t\t\t\t'400';\n\t\t}\n\t}\n\n\treturn style;\n}\n\nexport function getFacePreviewStyle( face ) {\n\treturn {\n\t\tfontFamily: formatFontFamily( face.fontFamily ),\n\t\tfontStyle: face.fontStyle || 'normal',\n\t\tfontWeight: face.fontWeight || '400',\n\t};\n}\n"],"mappings":"AAAA,SAASA,WAAWA,CAAEC,KAAK,EAAEC,OAAO,EAAG;EACtC;EACA,IAAKA,OAAO,CAACC,MAAM,KAAK,CAAC,EAAG;IAC3B,OAAO,IAAI;EACZ;EACA;EACAD,OAAO,CAACE,IAAI,CAAE,CAAEC,CAAC,EAAEC,CAAC,KAAMC,IAAI,CAACC,GAAG,CAAEP,KAAK,GAAGI,CAAE,CAAC,GAAGE,IAAI,CAACC,GAAG,CAAEP,KAAK,GAAGK,CAAE,CAAE,CAAC;EACzE;EACA,OAAOJ,OAAO,CAAE,CAAC,CAAE;AACpB;AAEA,SAASO,kBAAkBA,CAAEC,SAAS,EAAG;EACxC,MAAMC,MAAM,GAAG,EAAE;EAEjBD,SAAS,CAACE,OAAO,CAAIC,IAAI,IAAM;IAC9B,MAAMC,OAAO,GAAGC,MAAM,CAAEF,IAAI,CAACG,UAAW,CAAC,CAACC,KAAK,CAAE,GAAI,CAAC;IAEtD,IAAKH,OAAO,CAACX,MAAM,KAAK,CAAC,EAAG;MAC3B,MAAMe,KAAK,GAAGC,QAAQ,CAAEL,OAAO,CAAE,CAAC,CAAG,CAAC;MACtC,MAAMM,GAAG,GAAGD,QAAQ,CAAEL,OAAO,CAAE,CAAC,CAAG,CAAC;MAEpC,KAAM,IAAIO,CAAC,GAAGH,KAAK,EAAEG,CAAC,IAAID,GAAG,EAAEC,CAAC,IAAI,GAAG,EAAG;QACzCV,MAAM,CAACW,IAAI,CAAED,CAAE,CAAC;MACjB;IACD,CAAC,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aAAa,GAAGhC,kBAAkB,CAAE6B,WAAY,CAAC;MACvD,MAAMI,aAAa,GAAG1C,WAAW,CAAE,GAAG,EAAEyC,aAAc,CAAC;MACvDT,KAAK,CAAChB,UAAU,GAAGD,MAAM,CAAE2B,aAAc,CAAC,IAAI,KAAK;IACpD,CAAC,MAAM;MACNV,KAAK,CAACK,SAAS,GACZN,MAAM,CAACK,QAAQ,CAACjC,MAAM,IAAI4B,MAAM,CAACK,QAAQ,CAAE,CAAC,CAAE,CAACC,SAAS,IAC1D,QAAQ;MACTL,KAAK,CAAChB,UAAU,GACbe,MAAM,CAACK,QAAQ,CAACjC,MAAM,IACvBY,MAAM,CAAEgB,MAAM,CAACK,QAAQ,CAAE,CAAC,CAAE,CAACpB,UAAW,CAAC,IAC1C,KAAK;IACP;EACD;EAEA,OAAOgB,KAAK;AACb;AAEA,OAAO,SAASW,mBAAmBA,CAAE9B,IAAI,EAAG;EAC3C,OAAO;IACNoB,UAAU,EAAEV,gBAAgB,CAAEV,IAAI,CAACoB,UAAW,CAAC;IAC/CI,SAAS,EAAExB,IAAI,CAACwB,SAAS,IAAI,QAAQ;IACrCrB,UAAU,EAAEH,IAAI,CAACG,UAAU,IAAI;EAChC,CAAC;AACF"}
1
+ {"version":3,"names":["findNearest","input","numbers","length","sort","a","b","Math","abs","extractFontWeights","fontFaces","result","forEach","face","weights","String","fontWeight","split","start","parseInt","end","i","push","formatFontFamily","map","font","trim","startsWith","indexOf","join","getFamilyPreviewStyle","family","style","fontFamily","Array","isArray","fontFace","fontStyle","normalFaces","filter","toLowerCase","normalWeights","nearestWeight","getFacePreviewStyle"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/utils/preview-styles.js"],"sourcesContent":["function findNearest( input, numbers ) {\n\t// If the numbers array is empty, return null\n\tif ( numbers.length === 0 ) {\n\t\treturn null;\n\t}\n\t// Sort the array based on the absolute difference with the input\n\tnumbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );\n\t// Return the first element (which will be the nearest) from the sorted array\n\treturn numbers[ 0 ];\n}\n\nfunction extractFontWeights( fontFaces ) {\n\tconst result = [];\n\n\tfontFaces.forEach( ( face ) => {\n\t\tconst weights = String( face.fontWeight ).split( ' ' );\n\n\t\tif ( weights.length === 2 ) {\n\t\t\tconst start = parseInt( weights[ 0 ] );\n\t\t\tconst end = parseInt( weights[ 1 ] );\n\n\t\t\tfor ( let i = start; i <= end; i += 100 ) {\n\t\t\t\tresult.push( i );\n\t\t\t}\n\t\t} else if ( weights.length === 1 ) {\n\t\t\tresult.push( parseInt( weights[ 0 ] ) );\n\t\t}\n\t} );\n\n\treturn result;\n}\n\nexport function formatFontFamily( input ) {\n\treturn input\n\t\t.split( ',' )\n\t\t.map( ( font ) => {\n\t\t\tfont = font.trim(); // Remove any leading or trailing white spaces\n\t\t\t// If the font doesn't start with quotes and contains a space, then wrap in quotes.\n\t\t\t// Check that string starts with a single or double quote and not a space\n\t\t\tif (\n\t\t\t\t! ( font.startsWith( '\"' ) || font.startsWith( \"'\" ) ) &&\n\t\t\t\tfont.indexOf( ' ' ) !== -1\n\t\t\t) {\n\t\t\t\treturn `\"${ font }\"`;\n\t\t\t}\n\t\t\treturn font; // Return font as is if no transformation is needed\n\t\t} )\n\t\t.join( ', ' );\n}\n\nexport function getFamilyPreviewStyle( family ) {\n\tconst style = { fontFamily: formatFontFamily( family.fontFamily ) };\n\n\tif ( ! Array.isArray( family.fontFace ) ) {\n\t\tstyle.fontWeight = '400';\n\t\tstyle.fontStyle = 'normal';\n\t\treturn style;\n\t}\n\n\tif ( family.fontFace ) {\n\t\t//get all the font faces with normal style\n\t\tconst normalFaces = family.fontFace.filter(\n\t\t\t( face ) => face.fontStyle.toLowerCase() === 'normal'\n\t\t);\n\t\tif ( normalFaces.length > 0 ) {\n\t\t\tstyle.fontStyle = 'normal';\n\t\t\tconst normalWeights = extractFontWeights( normalFaces );\n\t\t\tconst nearestWeight = findNearest( 400, normalWeights );\n\t\t\tstyle.fontWeight = String( nearestWeight ) || '400';\n\t\t} else {\n\t\t\tstyle.fontStyle =\n\t\t\t\t( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||\n\t\t\t\t'normal';\n\t\t\tstyle.fontWeight =\n\t\t\t\t( family.fontFace.length &&\n\t\t\t\t\tString( family.fontFace[ 0 ].fontWeight ) ) ||\n\t\t\t\t'400';\n\t\t}\n\t}\n\n\treturn style;\n}\n\nexport function getFacePreviewStyle( face ) {\n\treturn {\n\t\tfontFamily: formatFontFamily( face.fontFamily ),\n\t\tfontStyle: face.fontStyle || 'normal',\n\t\tfontWeight: face.fontWeight || '400',\n\t};\n}\n"],"mappings":"AAAA,SAASA,WAAWA,CAAEC,KAAK,EAAEC,OAAO,EAAG;EACtC;EACA,IAAKA,OAAO,CAACC,MAAM,KAAK,CAAC,EAAG;IAC3B,OAAO,IAAI;EACZ;EACA;EACAD,OAAO,CAACE,IAAI,CAAE,CAAEC,CAAC,EAAEC,CAAC,KAAMC,IAAI,CAACC,GAAG,CAAEP,KAAK,GAAGI,CAAE,CAAC,GAAGE,IAAI,CAACC,GAAG,CAAEP,KAAK,GAAGK,CAAE,CAAE,CAAC;EACzE;EACA,OAAOJ,OAAO,CAAE,CAAC,CAAE;AACpB;AAEA,SAASO,kBAAkBA,CAAEC,SAAS,EAAG;EACxC,MAAMC,MAAM,GAAG,EAAE;EAEjBD,SAAS,CAACE,OAAO,CAAIC,IAAI,IAAM;IAC9B,MAAMC,OAAO,GAAGC,MAAM,CAAEF,IAAI,CAACG,UAAW,CAAC,CAACC,KAAK,CAAE,GAAI,CAAC;IAEtD,IAAKH,OAAO,CAACX,MAAM,KAAK,CAAC,EAAG;MAC3B,MAAMe,KAAK,GAAGC,QAAQ,CAAEL,OAAO,CAAE,CAAC,CAAG,CAAC;MACtC,MAAMM,GAAG,GAAGD,QAAQ,CAAEL,OAAO,CAAE,CAAC,CAAG,CAAC;MAEpC,KAAM,IAAIO,CAAC,GAAGH,KAAK,EAAEG,CAAC,IAA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S,CAACG,WAAW,CAAC,CAAC,KAAK,QAC9C,CAAC;IACD,IAAKF,WAAW,CAACnC,MAAM,GAAG,CAAC,EAAG;MAC7B6B,KAAK,CAACK,SAAS,GAAG,QAAQ;MAC1B,MAAMI,aAAa,GAAGhC,kBAAkB,CAAE6B,WAAY,CAAC;MACvD,MAAMI,aAAa,GAAG1C,WAAW,CAAE,GAAG,EAAEyC,aAAc,CAAC;MACvDT,KAAK,CAAChB,UAAU,GAAGD,MAAM,CAAE2B,aAAc,CAAC,IAAI,KAAK;IACpD,CAAC,MAAM;MACNV,KAAK,CAACK,SAAS,GACZN,MAAM,CAACK,QAAQ,CAACjC,MAAM,IAAI4B,MAAM,CAACK,QAAQ,CAAE,CAAC,CAAE,CAACC,SAAS,IAC1D,QAAQ;MACTL,KAAK,CAAChB,UAAU,GACbe,MAAM,CAACK,QAAQ,CAACjC,MAAM,IACvBY,MAAM,CAAEgB,MAAM,CAACK,QAAQ,CAAE,CAAC,CAAE,CAACpB,UAAW,CAAC,IAC1C,KAAK;IACP;EACD;EAEA,OAAOgB,KAAK;AACb;AAEA,OAAO,SAASW,mBAAmBA,CAAE9B,IAAI,EAAG;EAC3C,OAAO;IACNoB,UAAU,EAAEV,gBAAgB,CAAEV,IAAI,CAACoB,UAAW,CAAC;IAC/CI,SAAS,EAAExB,IAAI,CAACwB,SAAS,IAAI,QAAQ;IACrCrB,UAAU,EAAEH,IAAI,CAACG,UAAU,IAAI;EAChC,CAAC;AACF"}
@@ -92,6 +92,16 @@ function ScreenBlock({
92
92
  if (settings?.spacing?.blockGap && blockType?.supports?.spacing?.blockGap && (blockType?.supports?.spacing?.__experimentalSkipSerialization === true || blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(spacingType => spacingType === 'blockGap'))) {
93
93
  settings.spacing.blockGap = false;
94
94
  }
95
+
96
+ // Only allow `aspectRatio` support if the block is not the grouping block.
97
+ // The grouping block allows the user to use Group, Row and Stack variations,
98
+ // and it is highly likely that the user will not want to set an aspect ratio
99
+ // for all three at once. Until there is the ability to set a different aspect
100
+ // ratio for each variation, we disable the aspect ratio controls for the
101
+ // grouping block in global styles.
102
+ if (settings?.dimensions?.aspectRatio && name === 'core/group') {
103
+ settings.dimensions.aspectRatio = false;
104
+ }
95
105
  const blockVariations = useBlockVariations(name);
96
106
  const hasTypographyPanel = useHasTypographyPanel(settings);
97
107
  const hasColorPanel = useHasColorPanel(settings);
@@ -1 +1 @@
1
- {"version":3,"names":["getBlockType","privateApis","blockEditorPrivateApis","useMemo","useSelect","store","coreStore","PanelBody","__experimentalVStack","VStack","__experimentalHasSplitBorders","hasSplitBorders","__","sprintf","ScreenHeader","BlockPreviewPanel","unlock","Subtitle","useBlockVariations","VariationsPanel","applyFallbackStyle","border","hasColorOrWidth","color","width","style","undefined","applyAllFallbackStyles","top","right","bottom","left","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useGlobalSetting","useSettingsForBlockElement","useHasColorPanel","useHasEffectsPanel","useHasFiltersPanel","useHasImageSettingsPanel","useGlobalStyle","BorderPanel","StylesBorderPanel","ColorPanel","StylesColorPanel","TypographyPanel","StylesTypographyPanel","DimensionsPanel","StylesDimensionsPanel","EffectsPanel","StylesEffectsPanel","FiltersPanel","StylesFiltersPanel","ImageSettingsPanel","AdvancedPanel","StylesAdvancedPanel","ScreenBlock","name","variation","prefixParts","concat","prefix","join","shouldDecodeEncode","inheritedStyle","setStyle","userSettings","rawSettings","setSettings","settings","blockType","spacing","blockGap","supports","__experimentalSkipSerialization","some","spacingType","blockVariations","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasEffectsPanel","hasFiltersPanel","hasImageSettingsPanel","hasVariationsPanel","length","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","_links","currentBlockStyle","find","s","inheritedStyleWithLayout","layout","styleWithLayout","onChangeDimensions","newStyle","updatedStyle","onChangeLightbox","newSetting","lightbox","onChangeBorders","radius","newBorder","updatedBorder","createElement","Fragment","title","label","className","inheritedValue","value","onChange","includeLayoutControls","initialOpen"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tPanelBody,\n\t__experimentalVStack as VStack,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ScreenHeader from './header';\nimport BlockPreviewPanel from './block-preview-panel';\nimport { unlock } from '../../lock-unlock';\nimport Subtitle from './subtitle';\nimport { useBlockVariations, VariationsPanel } from './variations-panel';\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tconst hasColorOrWidth = border.color || border.width;\n\n\tif ( ! border.style && hasColorOrWidth ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\tif ( border.style && ! hasColorOrWidth ) {\n\t\treturn undefined;\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tuseHasColorPanel,\n\tuseHasEffectsPanel,\n\tuseHasFiltersPanel,\n\tuseHasImageSettingsPanel,\n\tuseGlobalStyle,\n\tBorderPanel: StylesBorderPanel,\n\tColorPanel: StylesColorPanel,\n\tTypographyPanel: StylesTypographyPanel,\n\tDimensionsPanel: StylesDimensionsPanel,\n\tEffectsPanel: StylesEffectsPanel,\n\tFiltersPanel: StylesFiltersPanel,\n\tImageSettingsPanel,\n\tAdvancedPanel: StylesAdvancedPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction ScreenBlock( { name, variation } ) {\n\tlet prefixParts = [];\n\tif ( variation ) {\n\t\tprefixParts = [ 'variations', variation ].concat( prefixParts );\n\t}\n\tconst prefix = prefixParts.join( '.' );\n\n\tconst [ style ] = useGlobalStyle( prefix, name, 'user', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ userSettings ] = useGlobalSetting( '', name, 'user' );\n\tconst [ rawSettings, setSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\tconst blockType = getBlockType( name );\n\n\t// Only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.\n\tif (\n\t\tsettings?.spacing?.blockGap &&\n\t\tblockType?.supports?.spacing?.blockGap &&\n\t\t( blockType?.supports?.spacing?.__experimentalSkipSerialization ===\n\t\t\ttrue ||\n\t\t\tblockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(\n\t\t\t\t( spacingType ) => spacingType === 'blockGap'\n\t\t\t) )\n\t) {\n\t\tsettings.spacing.blockGap = false;\n\t}\n\n\tconst blockVariations = useBlockVariations( name );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasEffectsPanel = useHasEffectsPanel( settings );\n\tconst hasFiltersPanel = useHasFiltersPanel( settings );\n\tconst hasImageSettingsPanel = useHasImageSettingsPanel(\n\t\tname,\n\t\tuserSettings,\n\t\tsettings\n\t);\n\tconst hasVariationsPanel = !! blockVariations?.length && ! variation;\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t};\n\t}, [] );\n\tconst currentBlockStyle = variation\n\t\t? blockVariations.find( ( s ) => s.name === variation )\n\t\t: null;\n\n\t// These intermediary objects are needed because the \"layout\" property is stored\n\t// in settings rather than styles.\n\tconst inheritedStyleWithLayout = useMemo( () => {\n\t\treturn {\n\t\t\t...inheritedStyle,\n\t\t\tlayout: settings.layout,\n\t\t};\n\t}, [ inheritedStyle, settings.layout ] );\n\tconst styleWithLayout = useMemo( () => {\n\t\treturn {\n\t\t\t...style,\n\t\t\tlayout: userSettings.layout,\n\t\t};\n\t}, [ style, userSettings.layout ] );\n\tconst onChangeDimensions = ( newStyle ) => {\n\t\tconst updatedStyle = { ...newStyle };\n\t\tdelete updatedStyle.layout;\n\t\tsetStyle( updatedStyle );\n\n\t\tif ( newStyle.layout !== userSettings.layout ) {\n\t\t\tsetSettings( {\n\t\t\t\t...userSettings,\n\t\t\t\tlayout: newStyle.layout,\n\t\t\t} );\n\t\t}\n\t};\n\tconst onChangeLightbox = ( newSetting ) => {\n\t\t// If the newSetting is undefined, this means that the user has deselected\n\t\t// (reset) the lightbox setting.\n\t\tif ( newSetting === undefined ) {\n\t\t\tsetSettings( {\n\t\t\t\t...rawSettings,\n\t\t\t\tlightbox: undefined,\n\t\t\t} );\n\n\t\t\t// Otherwise, we simply set the lightbox setting to the new value but\n\t\t\t// taking care of not overriding the other lightbox settings.\n\t\t} else {\n\t\t\tsetSettings( {\n\t\t\t\t...rawSettings,\n\t\t\t\tlightbox: {\n\t\t\t\t\t...rawSettings.lightbox,\n\t\t\t\t\t...newSetting,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t};\n\tconst onChangeBorders = ( newStyle ) => {\n\t\tif ( ! newStyle?.border ) {\n\t\t\tsetStyle( newStyle );\n\t\t\treturn;\n\t\t}\n\n\t\t// As Global Styles can't conditionally generate styles based on if\n\t\t// other style properties have been set, we need to force split\n\t\t// border definitions for user set global border styles. Border\n\t\t// radius is derived from the same property i.e. `border.radius` if\n\t\t// it is a string that is used. The longhand border radii styles are\n\t\t// only generated if that property is an object.\n\t\t//\n\t\t// For borders (color, style, and width) those are all properties on\n\t\t// the `border` style property. This means if the theme.json defined\n\t\t// split borders and the user condenses them into a flat border or\n\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\tconst { radius, ...newBorder } = newStyle.border;\n\t\tconst border = applyAllFallbackStyles( newBorder );\n\t\tconst updatedBorder = ! hasSplitBorders( border )\n\t\t\t? {\n\t\t\t\t\ttop: border,\n\t\t\t\t\tright: border,\n\t\t\t\t\tbottom: border,\n\t\t\t\t\tleft: border,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tcolor: null,\n\t\t\t\t\tstyle: null,\n\t\t\t\t\twidth: null,\n\t\t\t\t\t...border,\n\t\t\t };\n\n\t\tsetStyle( { ...newStyle, border: { ...updatedBorder, radius } } );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ variation ? currentBlockStyle.label : blockType.title }\n\t\t\t/>\n\t\t\t<BlockPreviewPanel name={ name } variation={ variation } />\n\t\t\t{ hasVariationsPanel && (\n\t\t\t\t<div className=\"edit-site-global-styles-screen-variations\">\n\t\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t\t<Subtitle>{ __( 'Style Variations' ) }</Subtitle>\n\t\t\t\t\t\t<VariationsPanel name={ name } />\n\t\t\t\t\t</VStack>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ hasColorPanel && (\n\t\t\t\t<StylesColorPanel\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasTypographyPanel && (\n\t\t\t\t<StylesTypographyPanel\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasDimensionsPanel && (\n\t\t\t\t<StylesDimensionsPanel\n\t\t\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\t\t\tvalue={ styleWithLayout }\n\t\t\t\t\tonChange={ onChangeDimensions }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tincludeLayoutControls\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasBorderPanel && (\n\t\t\t\t<StylesBorderPanel\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ onChangeBorders }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasEffectsPanel && (\n\t\t\t\t<StylesEffectsPanel\n\t\t\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\t\t\tvalue={ styleWithLayout }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tincludeLayoutControls\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasFiltersPanel && (\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\t\t\tvalue={ styleWithLayout }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tincludeLayoutControls\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasImageSettingsPanel && (\n\t\t\t\t<ImageSettingsPanel\n\t\t\t\t\tonChange={ onChangeLightbox }\n\t\t\t\t\tvalue={ userSettings }\n\t\t\t\t\tinheritedValue={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ canEditCSS && (\n\t\t\t\t<PanelBody title={ __( 'Advanced' ) } initialOpen={ false }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Table'.\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tblockType?.title\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<StylesAdvancedPanel\n\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ScreenBlock;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,SAAS,EACTC,oBAAoB,IAAIC,MAAM,EAC9BC,6BAA6B,IAAIC,eAAe,QAC1C,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,UAAU;AACnC,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,SAASC,MAAM,QAAQ,mBAAmB;AA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aAAA,YACGlG,OAAO;EACR;EACAD,EAAE,CACD,2IACD,CAAC,EACD2D,SAAS,EAAE0C,KACZ,CACE,CAAC,EACJF,aAAA,CAACvD,mBAAmB;IACnB6D,KAAK,EAAG5F,KAAO;IACf6F,QAAQ,EAAGpD,QAAU;IACrBkD,cAAc,EAAGnD;EAAgB,CACjC,CACS,CAEX,CAAC;AAEL;AAEA,eAAeR,WAAW"}
1
+ {"version":3,"names":["getBlockType","privateApis","blockEditorPrivateApis","useMemo","useSelect","store","coreStore","PanelBody","__experimentalVStack","VStack","__experimentalHasSplitBorders","hasSplitBorders","__","sprintf","ScreenHeader","BlockPreviewPanel","unlock","Subtitle","useBlockVariations","VariationsPanel","applyFallbackStyle","border","hasColorOrWidth","color","width","style","undefined","applyAllFallbackStyles","top","right","bottom","left","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useGlobalSetting","useSettingsForBlockElement","useHasColorPanel","useHasEffectsPanel","useHasFiltersPanel","useHasImageSettingsPanel","useGlobalStyle","BorderPanel","StylesBorderPanel","ColorPanel","StylesColorPanel","TypographyPanel","StylesTypographyPanel","DimensionsPanel","StylesDimensionsPanel","EffectsPanel","StylesEffectsPanel","FiltersPanel","StylesFiltersPanel","ImageSettingsPanel","AdvancedPanel","StylesAdvancedPanel","ScreenBlock","name","variation","prefixParts","concat","prefix","join","shouldDecodeEncode","inheritedStyle","setStyle","userSettings","rawSettings","setSettings","settings","blockType","spacing","blockGap","supports","__experimentalSkipSerialization","some","spacingType","dimensions","aspectRatio","blockVariations","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasEffectsPanel","hasFiltersPanel","hasImageSettingsPanel","hasVariationsPanel","length","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","_links","currentBlockStyle","find","s","inheritedStyleWithLayout","layout","styleWithLayout","onChangeDimensions","newStyle","updatedStyle","onChangeLightbox","newSetting","lightbox","onChangeBorders","radius","newBorder","updatedBorder","createElement","Fragment","title","label","className","inheritedValue","value","onChange","includeLayoutControls","initialOpen"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tPanelBody,\n\t__experimentalVStack as VStack,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ScreenHeader from './header';\nimport BlockPreviewPanel from './block-preview-panel';\nimport { unlock } from '../../lock-unlock';\nimport Subtitle from './subtitle';\nimport { useBlockVariations, VariationsPanel } from './variations-panel';\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tconst hasColorOrWidth = border.color || border.width;\n\n\tif ( ! border.style && hasColorOrWidth ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\tif ( border.style && ! hasColorOrWidth ) {\n\t\treturn undefined;\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tuseHasColorPanel,\n\tuseHasEffectsPanel,\n\tuseHasFiltersPanel,\n\tuseHasImageSettingsPanel,\n\tuseGlobalStyle,\n\tBorderPanel: StylesBorderPanel,\n\tColorPanel: StylesColorPanel,\n\tTypographyPanel: StylesTypographyPanel,\n\tDimensionsPanel: StylesDimensionsPanel,\n\tEffectsPanel: StylesEffectsPanel,\n\tFiltersPanel: StylesFiltersPanel,\n\tImageSettingsPanel,\n\tAdvancedPanel: StylesAdvancedPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction ScreenBlock( { name, variation } ) {\n\tlet prefixParts = [];\n\tif ( variation ) {\n\t\tprefixParts = [ 'variations', variation ].concat( prefixParts );\n\t}\n\tconst prefix = prefixParts.join( '.' );\n\n\tconst [ style ] = useGlobalStyle( prefix, name, 'user', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {\n\t\tshouldDecodeEncode: false,\n\t} );\n\tconst [ userSettings ] = useGlobalSetting( '', name, 'user' );\n\tconst [ rawSettings, setSettings ] = useGlobalSetting( '', name );\n\tconst settings = useSettingsForBlockElement( rawSettings, name );\n\tconst blockType = getBlockType( name );\n\n\t// Only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.\n\tif (\n\t\tsettings?.spacing?.blockGap &&\n\t\tblockType?.supports?.spacing?.blockGap &&\n\t\t( blockType?.supports?.spacing?.__experimentalSkipSerialization ===\n\t\t\ttrue ||\n\t\t\tblockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(\n\t\t\t\t( spacingType ) => spacingType === 'blockGap'\n\t\t\t) )\n\t) {\n\t\tsettings.spacing.blockGap = false;\n\t}\n\n\t// Only allow `aspectRatio` support if the block is not the grouping block.\n\t// The grouping block allows the user to use Group, Row and Stack variations,\n\t// and it is highly likely that the user will not want to set an aspect ratio\n\t// for all three at once. Until there is the ability to set a different aspect\n\t// ratio for each variation, we disable the aspect ratio controls for the\n\t// grouping block in global styles.\n\tif ( settings?.dimensions?.aspectRatio && name === 'core/group' ) {\n\t\tsettings.dimensions.aspectRatio = false;\n\t}\n\n\tconst blockVariations = useBlockVariations( name );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasEffectsPanel = useHasEffectsPanel( settings );\n\tconst hasFiltersPanel = useHasFiltersPanel( settings );\n\tconst hasImageSettingsPanel = useHasImageSettingsPanel(\n\t\tname,\n\t\tuserSettings,\n\t\tsettings\n\t);\n\tconst hasVariationsPanel = !! blockVariations?.length && ! variation;\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS: !! globalStyles?._links?.[ 'wp:action-edit-css' ],\n\t\t};\n\t}, [] );\n\tconst currentBlockStyle = variation\n\t\t? blockVariations.find( ( s ) => s.name === variation )\n\t\t: null;\n\n\t// These intermediary objects are needed because the \"layout\" property is stored\n\t// in settings rather than styles.\n\tconst inheritedStyleWithLayout = useMemo( () => {\n\t\treturn {\n\t\t\t...inheritedStyle,\n\t\t\tlayout: settings.layout,\n\t\t};\n\t}, [ inheritedStyle, settings.layout ] );\n\tconst styleWithLayout = useMemo( () => {\n\t\treturn {\n\t\t\t...style,\n\t\t\tlayout: userSettings.layout,\n\t\t};\n\t}, [ style, userSettings.layout ] );\n\tconst onChangeDimensions = ( newStyle ) => {\n\t\tconst updatedStyle = { ...newStyle };\n\t\tdelete updatedStyle.layout;\n\t\tsetStyle( updatedStyle );\n\n\t\tif ( newStyle.layout !== userSettings.layout ) {\n\t\t\tsetSettings( {\n\t\t\t\t...userSettings,\n\t\t\t\tlayout: newStyle.layout,\n\t\t\t} );\n\t\t}\n\t};\n\tconst onChangeLightbox = ( newSetting ) => {\n\t\t// If the newSetting is undefined, this means that the user has deselected\n\t\t// (reset) the lightbox setting.\n\t\tif ( newSetting === undefined ) {\n\t\t\tsetSettings( {\n\t\t\t\t...rawSettings,\n\t\t\t\tlightbox: undefined,\n\t\t\t} );\n\n\t\t\t// Otherwise, we simply set the lightbox setting to the new value but\n\t\t\t// taking care of not overriding the other lightbox settings.\n\t\t} else {\n\t\t\tsetSettings( {\n\t\t\t\t...rawSettings,\n\t\t\t\tlightbox: {\n\t\t\t\t\t...rawSettings.lightbox,\n\t\t\t\t\t...newSetting,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t};\n\tconst onChangeBorders = ( newStyle ) => {\n\t\tif ( ! newStyle?.border ) {\n\t\t\tsetStyle( newStyle );\n\t\t\treturn;\n\t\t}\n\n\t\t// As Global Styles can't conditionally generate styles based on if\n\t\t// other style properties have been set, we need to force split\n\t\t// border definitions for user set global border styles. Border\n\t\t// radius is derived from the same property i.e. `border.radius` if\n\t\t// it is a string that is used. The longhand border radii styles are\n\t\t// only generated if that property is an object.\n\t\t//\n\t\t// For borders (color, style, and width) those are all properties on\n\t\t// the `border` style property. This means if the theme.json defined\n\t\t// split borders and the user condenses them into a flat border or\n\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\tconst { radius, ...newBorder } = newStyle.border;\n\t\tconst border = applyAllFallbackStyles( newBorder );\n\t\tconst updatedBorder = ! hasSplitBorders( border )\n\t\t\t? {\n\t\t\t\t\ttop: border,\n\t\t\t\t\tright: border,\n\t\t\t\t\tbottom: border,\n\t\t\t\t\tleft: border,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tcolor: null,\n\t\t\t\t\tstyle: null,\n\t\t\t\t\twidth: null,\n\t\t\t\t\t...border,\n\t\t\t };\n\n\t\tsetStyle( { ...newStyle, border: { ...updatedBorder, radius } } );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ variation ? currentBlockStyle.label : blockType.title }\n\t\t\t/>\n\t\t\t<BlockPreviewPanel name={ name } variation={ variation } />\n\t\t\t{ hasVariationsPanel && (\n\t\t\t\t<div className=\"edit-site-global-styles-screen-variations\">\n\t\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t\t<Subtitle>{ __( 'Style Variations' ) }</Subtitle>\n\t\t\t\t\t\t<VariationsPanel name={ name } />\n\t\t\t\t\t</VStack>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ hasColorPanel && (\n\t\t\t\t<StylesColorPanel\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasTypographyPanel && (\n\t\t\t\t<StylesTypographyPanel\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasDimensionsPanel && (\n\t\t\t\t<StylesDimensionsPanel\n\t\t\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\t\t\tvalue={ styleWithLayout }\n\t\t\t\t\tonChange={ onChangeDimensions }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tincludeLayoutControls\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasBorderPanel && (\n\t\t\t\t<StylesBorderPanel\n\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\tvalue={ style }\n\t\t\t\t\tonChange={ onChangeBorders }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasEffectsPanel && (\n\t\t\t\t<StylesEffectsPanel\n\t\t\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\t\t\tvalue={ styleWithLayout }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tincludeLayoutControls\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasFiltersPanel && (\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tinheritedValue={ inheritedStyleWithLayout }\n\t\t\t\t\tvalue={ styleWithLayout }\n\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tincludeLayoutControls\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasImageSettingsPanel && (\n\t\t\t\t<ImageSettingsPanel\n\t\t\t\t\tonChange={ onChangeLightbox }\n\t\t\t\t\tvalue={ userSettings }\n\t\t\t\t\tinheritedValue={ settings }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ canEditCSS && (\n\t\t\t\t<PanelBody title={ __( 'Advanced' ) } initialOpen={ false }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Table'.\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tblockType?.title\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<StylesAdvancedPanel\n\t\t\t\t\t\tvalue={ style }\n\t\t\t\t\t\tonChange={ setStyle }\n\t\t\t\t\t\tinheritedValue={ inheritedStyle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ScreenBlock;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;A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IAClBiE,cAAc,EAAGlB,wBAA0B;IAC3CmB,KAAK,EAAGjB,eAAiB;IACzBkB,QAAQ,EAAGtD,QAAU;IACrBI,QAAQ,EAAGA,QAAU;IACrBmD,qBAAqB;EAAA,CACrB,CACD,EACClC,qBAAqB,IACtB0B,aAAA,CAAC3D,kBAAkB;IAClBkE,QAAQ,EAAGd,gBAAkB;IAC7Ba,KAAK,EAAGpD,YAAc;IACtBmD,cAAc,EAAGhD;EAAU,CAC3B,CACD,EAECoB,UAAU,IACXuB,aAAA,CAAC1G,SAAS;IAAC4G,KAAK,EAAGvG,EAAE,CAAE,UAAW,CAAG;IAAC8G,WAAW,EAAG;EAAO,GAC1DT,aAAA,YACGpG,OAAO;EACR;EACAD,EAAE,CACD,2IACD,CAAC,EACD2D,SAAS,EAAE4C,KACZ,CACE,CAAC,EACJF,aAAA,CAACzD,mBAAmB;IACnB+D,KAAK,EAAG9F,KAAO;IACf+F,QAAQ,EAAGtD,QAAU;IACrBoD,cAAc,EAAGrD;EAAgB,CACjC,CACS,CAEX,CAAC;AAEL;AAEA,eAAeR,WAAW"}
@@ -4,6 +4,8 @@ import { createElement, Fragment } from "react";
4
4
  */
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { __experimentalVStack as VStack } from '@wordpress/components';
7
+ import { store as editorStore } from '@wordpress/editor';
8
+ import { useSelect } from '@wordpress/data';
7
9
 
8
10
  /**
9
11
  * Internal dependencies
@@ -12,6 +14,7 @@ import TypographyElements from './typogrphy-elements';
12
14
  import FontFamilies from './font-families';
13
15
  import ScreenHeader from './header';
14
16
  function ScreenTypography() {
17
+ const fontLibraryEnabled = useSelect(select => select(editorStore).getEditorSettings().fontLibraryEnabled, []);
15
18
  return createElement(Fragment, null, createElement(ScreenHeader, {
16
19
  title: __('Typography'),
17
20
  description: __('Manage the typography settings for different elements.')
@@ -19,7 +22,7 @@ function ScreenTypography() {
19
22
  className: "edit-site-global-styles-screen-typography"
20
23
  }, createElement(VStack, {
21
24
  spacing: 6
22
- }, !window.__experimentalDisableFontLibrary && createElement(FontFamilies, null), createElement(TypographyElements, null))));
25
+ }, fontLibraryEnabled && createElement(FontFamilies, null), createElement(TypographyElements, null))));
23
26
  }
24
27
  export default ScreenTypography;
25
28
  //# sourceMappingURL=screen-typography.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","__experimentalVStack","VStack","TypographyElements","FontFamilies","ScreenHeader","ScreenTypography","createElement","Fragment","title","description","className","spacing","window","__experimentalDisableFontLibrary"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-typography.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport TypographyElements from './typogrphy-elements';\nimport FontFamilies from './font-families';\nimport ScreenHeader from './header';\n\nfunction ScreenTypography() {\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Typography' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Manage the typography settings for different elements.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<div className=\"edit-site-global-styles-screen-typography\">\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t{ ! window.__experimentalDisableFontLibrary && (\n\t\t\t\t\t\t<FontFamilies />\n\t\t\t\t\t) }\n\t\t\t\t\t<TypographyElements />\n\t\t\t\t</VStack>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ScreenTypography;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;;AAEtE;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,sBAAsB;AACrD,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,YAAY,MAAM,UAAU;AAEnC,SAASC,gBAAgBA,CAAA,EAAG;EAC3B,OACCC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACF,YAAY;IACZI,KAAK,EAAGT,EAAE,CAAE,YAAa,CAAG;IAC5BU,WAAW,EAAGV,EAAE,CACf,wDACD;EAAG,CACH,CAAC,EACFO,aAAA;IAAKI,SAAS,EAAC;EAA2C,GACzDJ,aAAA,CAACL,MAAM;IAACU,OAAO,EAAG;EAAG,GAClB,CAAEC,MAAM,CAACC,gCAAgC,IAC1CP,aAAA,CAACH,YAAY,MAAE,CACf,EACDG,aAAA,CAACJ,kBAAkB,MAAE,CACd,CACJ,CACJ,CAAC;AAEL;AAEA,eAAeG,gBAAgB"}
1
+ {"version":3,"names":["__","__experimentalVStack","VStack","store","editorStore","useSelect","TypographyElements","FontFamilies","ScreenHeader","ScreenTypography","fontLibraryEnabled","select","getEditorSettings","createElement","Fragment","title","description","className","spacing"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-typography.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport TypographyElements from './typogrphy-elements';\nimport FontFamilies from './font-families';\nimport ScreenHeader from './header';\n\nfunction ScreenTypography() {\n\tconst fontLibraryEnabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().fontLibraryEnabled,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Typography' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Manage the typography settings for different elements.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<div className=\"edit-site-global-styles-screen-typography\">\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t{ fontLibraryEnabled && <FontFamilies /> }\n\t\t\t\t\t<TypographyElements />\n\t\t\t\t</VStack>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ScreenTypography;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,oBAAoB,IAAIC,MAAM,QAAQ,uBAAuB;AACtE,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,sBAAsB;AACrD,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,YAAY,MAAM,UAAU;AAEnC,SAASC,gBAAgBA,CAAA,EAAG;EAC3B,MAAMC,kBAAkB,GAAGL,SAAS,CACjCM,MAAM,IACPA,MAAM,CAAEP,WAAY,CAAC,CAACQ,iBAAiB,CAAC,CAAC,CAACF,kBAAkB,EAC7D,EACD,CAAC;EAED,OACCG,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACL,YAAY;IACZO,KAAK,EAAGf,EAAE,CAAE,YAAa,CAAG;IAC5BgB,WAAW,EAAGhB,EAAE,CACf,wDACD;EAAG,CACH,CAAC,EACFa,aAAA;IAAKI,SAAS,EAAC;EAA2C,GACzDJ,aAAA,CAACX,MAAM;IAACgB,OAAO,EAAG;EAAG,GAClBR,kBAAkB,IAAIG,aAAA,CAACN,YAAY,MAAE,CAAC,EACxCM,aAAA,CAACP,kBAAkB,MAAE,CACd,CACJ,CACJ,CAAC;AAEL;AAEA,eAAeG,gBAAgB"}
@@ -40,16 +40,17 @@ export function useIsSiteEditorLoading() {
40
40
  useEffect(() => {
41
41
  if (inLoadingPause) {
42
42
  /*
43
- * We're using an arbitrary 1s timeout here to catch brief moments
44
- * without any resolving selectors that would result in displaying
45
- * brief flickers of loading state and loaded state.
43
+ * We're using an arbitrary 100ms timeout here to catch brief
44
+ * moments without any resolving selectors that would result in
45
+ * displaying brief flickers of loading state and loaded state.
46
46
  *
47
47
  * It's worth experimenting with different values, since this also
48
- * adds 1s of artificial delay after loading has finished.
48
+ * adds 100ms of artificial delay after loading has finished.
49
49
  */
50
+ const ARTIFICIAL_DELAY = 100;
50
51
  const timeout = setTimeout(() => {
51
52
  setLoaded(true);
52
- }, 1000);
53
+ }, ARTIFICIAL_DELAY);
53
54
  return () => {
54
55
  clearTimeout(timeout);
55
56
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","useSelect","store","coreStore","useEditedEntityRecord","MAX_LOADING_TIME","useIsSiteEditorLoading","isLoaded","hasLoadedPost","loaded","setLoaded","inLoadingPause","select","hasResolvingSelectors","timeout","setTimeout","clearTimeout"],"sources":["@wordpress/edit-site/src/components/layout/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst MAX_LOADING_TIME = 10000; // 10 seconds\n\nexport function useIsSiteEditorLoading() {\n\tconst { isLoaded: hasLoadedPost } = useEditedEntityRecord();\n\tconst [ loaded, setLoaded ] = useState( false );\n\tconst inLoadingPause = useSelect(\n\t\t( select ) => {\n\t\t\tconst hasResolvingSelectors =\n\t\t\t\tselect( coreStore ).hasResolvingSelectors();\n\t\t\treturn ! loaded && ! hasResolvingSelectors;\n\t\t},\n\t\t[ loaded ]\n\t);\n\n\t/*\n\t * If the maximum expected loading time has passed, we're marking the\n\t * editor as loaded, in order to prevent any failed requests from blocking\n\t * the editor canvas from appearing.\n\t */\n\tuseEffect( () => {\n\t\tlet timeout;\n\n\t\tif ( ! loaded ) {\n\t\t\ttimeout = setTimeout( () => {\n\t\t\t\tsetLoaded( true );\n\t\t\t}, MAX_LOADING_TIME );\n\t\t}\n\n\t\treturn () => {\n\t\t\tclearTimeout( timeout );\n\t\t};\n\t}, [ loaded ] );\n\n\tuseEffect( () => {\n\t\tif ( inLoadingPause ) {\n\t\t\t/*\n\t\t\t * We're using an arbitrary 1s timeout here to catch brief moments\n\t\t\t * without any resolving selectors that would result in displaying\n\t\t\t * brief flickers of loading state and loaded state.\n\t\t\t *\n\t\t\t * It's worth experimenting with different values, since this also\n\t\t\t * adds 1s of artificial delay after loading has finished.\n\t\t\t */\n\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\tsetLoaded( true );\n\t\t\t}, 1000 );\n\n\t\t\treturn () => {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t};\n\t\t}\n\t}, [ inLoadingPause ] );\n\n\treturn ! loaded || ! hasLoadedPost;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,6BAA6B;AAE/D,MAAMC,gBAAgB,GAAG,KAAK,CAAC,CAAC;;AAEhC,OAAO,SAASC,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAEC,QAAQ,EAAEC;EAAc,CAAC,GAAGJ,qBAAqB,CAAC,CAAC;EAC3D,MAAM,CAAEK,MAAM,EAAEC,SAAS,CAAE,GAAGV,QAAQ,CAAE,KAAM,CAAC;EAC/C,MAAMW,cAAc,GAAGV,SAAS,CAC7BW,MAAM,IAAM;IACb,MAAMC,qBAAqB,GAC1BD,MAAM,CAAET,SAAU,CAAC,CAACU,qBAAqB,CAAC,CAAC;IAC5C,OAAO,CAAEJ,MAAM,IAAI,CAAEI,qBAAqB;EAC3C,CAAC,EACD,CAAEJ,MAAM,CACT,CAAC;;EAED;AACD;AACA;AACA;AACA;EACCV,SAAS,CAAE,MAAM;IAChB,IAAIe,OAAO;IAEX,IAAK,CAAEL,MAAM,EAAG;MACfK,OAAO,GAAGC,UAAU,CAAE,MAAM;QAC3BL,SAAS,CAAE,IAAK,CAAC;MAClB,CAAC,EAAEL,gBAAiB,CAAC;IACtB;IAEA,OAAO,MAAM;MACZW,YAAY,CAAEF,OAAQ,CAAC;IACxB,CAAC;EACF,CAAC,EAAE,CAAEL,MAAM,CAAG,CAAC;EAEfV,SAAS,CAAE,MAAM;IAChB,IAAKY,cAAc,EAAG;MACrB;AACH;AACA;AACA;AACA;AACA;AACA;AACA;MACG,MAAMG,OAAO,GAAGC,UAAU,CAAE,MAAM;QACjCL,SAAS,CAAE,IAAK,CAAC;MAClB,CAAC,EAAE,IAAK,CAAC;MAET,OAAO,MAAM;QACZM,YAAY,CAAEF,OAAQ,CAAC;MACxB,CAAC;IACF;EACD,CAAC,EAAE,CAAEH,cAAc,CAAG,CAAC;EAEvB,OAAO,CAAEF,MAAM,IAAI,CAAED,aAAa;AACnC"}
1
+ {"version":3,"names":["useEffect","useState","useSelect","store","coreStore","useEditedEntityRecord","MAX_LOADING_TIME","useIsSiteEditorLoading","isLoaded","hasLoadedPost","loaded","setLoaded","inLoadingPause","select","hasResolvingSelectors","timeout","setTimeout","clearTimeout","ARTIFICIAL_DELAY"],"sources":["@wordpress/edit-site/src/components/layout/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst MAX_LOADING_TIME = 10000; // 10 seconds\n\nexport function useIsSiteEditorLoading() {\n\tconst { isLoaded: hasLoadedPost } = useEditedEntityRecord();\n\tconst [ loaded, setLoaded ] = useState( false );\n\tconst inLoadingPause = useSelect(\n\t\t( select ) => {\n\t\t\tconst hasResolvingSelectors =\n\t\t\t\tselect( coreStore ).hasResolvingSelectors();\n\t\t\treturn ! loaded && ! hasResolvingSelectors;\n\t\t},\n\t\t[ loaded ]\n\t);\n\n\t/*\n\t * If the maximum expected loading time has passed, we're marking the\n\t * editor as loaded, in order to prevent any failed requests from blocking\n\t * the editor canvas from appearing.\n\t */\n\tuseEffect( () => {\n\t\tlet timeout;\n\n\t\tif ( ! loaded ) {\n\t\t\ttimeout = setTimeout( () => {\n\t\t\t\tsetLoaded( true );\n\t\t\t}, MAX_LOADING_TIME );\n\t\t}\n\n\t\treturn () => {\n\t\t\tclearTimeout( timeout );\n\t\t};\n\t}, [ loaded ] );\n\n\tuseEffect( () => {\n\t\tif ( inLoadingPause ) {\n\t\t\t/*\n\t\t\t * We're using an arbitrary 100ms timeout here to catch brief\n\t\t\t * moments without any resolving selectors that would result in\n\t\t\t * displaying brief flickers of loading state and loaded state.\n\t\t\t *\n\t\t\t * It's worth experimenting with different values, since this also\n\t\t\t * adds 100ms of artificial delay after loading has finished.\n\t\t\t */\n\t\t\tconst ARTIFICIAL_DELAY = 100;\n\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\tsetLoaded( true );\n\t\t\t}, ARTIFICIAL_DELAY );\n\n\t\t\treturn () => {\n\t\t\t\tclearTimeout( timeout );\n\t\t\t};\n\t\t}\n\t}, [ inLoadingPause ] );\n\n\treturn ! loaded || ! hasLoadedPost;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,6BAA6B;AAE/D,MAAMC,gBAAgB,GAAG,KAAK,CAAC,CAAC;;AAEhC,OAAO,SAASC,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAEC,QAAQ,EAAEC;EAAc,CAAC,GAAGJ,qBAAqB,CAAC,CAAC;EAC3D,MAAM,CAAEK,MAAM,EAAEC,SAAS,CAAE,GAAGV,QAAQ,CAAE,KAAM,CAAC;EAC/C,MAAMW,cAAc,GAAGV,SAAS,CAC7BW,MAAM,IAAM;IACb,MAAMC,qBAAqB,GAC1BD,MAAM,CAAET,SAAU,CAAC,CAACU,qBAAqB,CAAC,CAAC;IAC5C,OAAO,CA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