@wordpress/edit-site 5.31.0 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-editor/editor-canvas.js +8 -1
  3. package/build/components/block-editor/editor-canvas.js.map +1 -1
  4. package/build/components/block-editor/site-editor-canvas.js +15 -4
  5. package/build/components/block-editor/site-editor-canvas.js.map +1 -1
  6. package/build/components/editor/index.js +12 -3
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor-canvas-container/index.js +1 -2
  9. package/build/components/editor-canvas-container/index.js.map +1 -1
  10. package/build/components/global-styles/background-panel.js +38 -0
  11. package/build/components/global-styles/background-panel.js.map +1 -0
  12. package/build/components/global-styles/font-families.js +1 -1
  13. package/build/components/global-styles/font-families.js.map +1 -1
  14. package/build/components/global-styles/font-library-modal/context.js +38 -9
  15. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  16. package/build/components/global-styles/font-library-modal/utils/index.js +20 -2
  17. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  18. package/build/components/global-styles/palette.js +3 -1
  19. package/build/components/global-styles/palette.js.map +1 -1
  20. package/build/components/global-styles/preview-colors.js +2 -2
  21. package/build/components/global-styles/preview-colors.js.map +1 -1
  22. package/build/components/global-styles/root-menu.js +8 -2
  23. package/build/components/global-styles/root-menu.js.map +1 -1
  24. package/build/components/global-styles/screen-background.js +34 -0
  25. package/build/components/global-styles/screen-background.js.map +1 -0
  26. package/build/components/global-styles/screen-color-palette.js +2 -2
  27. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  28. package/build/components/global-styles/screen-colors.js +6 -4
  29. package/build/components/global-styles/screen-colors.js.map +1 -1
  30. package/build/components/global-styles/screen-style-variations.js +3 -37
  31. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  32. package/build/components/global-styles/screen-typography.js +6 -6
  33. package/build/components/global-styles/screen-typography.js.map +1 -1
  34. package/build/components/global-styles/style-variations-container.js +5 -2
  35. package/build/components/global-styles/style-variations-container.js.map +1 -1
  36. package/build/components/global-styles/ui.js +4 -1
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/global-styles/variations/variations-color.js +10 -3
  39. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  40. package/build/components/global-styles/variations/variations-typography.js +9 -2
  41. package/build/components/global-styles/variations/variations-typography.js.map +1 -1
  42. package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
  43. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  44. package/build/components/layout/animation.js +129 -0
  45. package/build/components/layout/animation.js.map +1 -0
  46. package/build/components/layout/index.js +9 -17
  47. package/build/components/layout/index.js.map +1 -1
  48. package/build/components/layout/router.js +21 -18
  49. package/build/components/layout/router.js.map +1 -1
  50. package/build/components/page-pages/index.js +19 -17
  51. package/build/components/page-pages/index.js.map +1 -1
  52. package/build/components/page-patterns/index.js +18 -28
  53. package/build/components/page-patterns/index.js.map +1 -1
  54. package/build/components/page-patterns/search-items.js +16 -58
  55. package/build/components/page-patterns/search-items.js.map +1 -1
  56. package/build/components/page-templates-template-parts/actions.js +54 -41
  57. package/build/components/page-templates-template-parts/actions.js.map +1 -1
  58. package/build/components/page-templates-template-parts/index.js +26 -59
  59. package/build/components/page-templates-template-parts/index.js.map +1 -1
  60. package/build/components/plugin-template-setting-panel/index.js +12 -1
  61. package/build/components/plugin-template-setting-panel/index.js.map +1 -1
  62. package/build/components/save-button/index.js +45 -16
  63. package/build/components/save-button/index.js.map +1 -1
  64. package/build/components/save-hub/index.js +8 -112
  65. package/build/components/save-hub/index.js.map +1 -1
  66. package/build/components/sidebar/index.js +1 -5
  67. package/build/components/sidebar/index.js.map +1 -1
  68. package/build/components/sidebar-dataviews/default-views.js +1 -1
  69. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  70. package/build/components/sidebar-dataviews/index.js +1 -1
  71. package/build/components/sidebar-dataviews/index.js.map +1 -1
  72. package/build/components/sidebar-edit-mode/index.js +1 -2
  73. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  74. package/build/components/sidebar-edit-mode/page-panels/index.js +5 -15
  75. package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  76. package/build/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  77. package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  78. package/build/components/sidebar-edit-mode/template-panel/index.js +10 -16
  79. package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-details-footer/index.js +5 -1
  81. package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-global-styles/index.js +10 -5
  83. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -5
  85. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  86. package/build/components/style-book/index.js +1 -1
  87. package/build/components/style-book/index.js.map +1 -1
  88. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  89. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  90. package/build/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  91. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  92. package/build/hooks/index.js +0 -1
  93. package/build/hooks/index.js.map +1 -1
  94. package/build/store/selectors.js +1 -9
  95. package/build/store/selectors.js.map +1 -1
  96. package/build-module/components/block-editor/editor-canvas.js +8 -1
  97. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  98. package/build-module/components/block-editor/site-editor-canvas.js +15 -4
  99. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  100. package/build-module/components/editor/index.js +13 -4
  101. package/build-module/components/editor/index.js.map +1 -1
  102. package/build-module/components/editor-canvas-container/index.js +1 -2
  103. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  104. package/build-module/components/global-styles/background-panel.js +31 -0
  105. package/build-module/components/global-styles/background-panel.js.map +1 -0
  106. package/build-module/components/global-styles/font-families.js +1 -1
  107. package/build-module/components/global-styles/font-families.js.map +1 -1
  108. package/build-module/components/global-styles/font-library-modal/context.js +38 -9
  109. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  110. package/build-module/components/global-styles/font-library-modal/utils/index.js +20 -2
  111. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  112. package/build-module/components/global-styles/palette.js +3 -1
  113. package/build-module/components/global-styles/palette.js.map +1 -1
  114. package/build-module/components/global-styles/preview-colors.js +2 -2
  115. package/build-module/components/global-styles/preview-colors.js.map +1 -1
  116. package/build-module/components/global-styles/root-menu.js +9 -3
  117. package/build-module/components/global-styles/root-menu.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background.js +26 -0
  119. package/build-module/components/global-styles/screen-background.js.map +1 -0
  120. package/build-module/components/global-styles/screen-color-palette.js +2 -2
  121. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  122. package/build-module/components/global-styles/screen-colors.js +6 -4
  123. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  124. package/build-module/components/global-styles/screen-style-variations.js +4 -38
  125. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  126. package/build-module/components/global-styles/screen-typography.js +6 -6
  127. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  128. package/build-module/components/global-styles/style-variations-container.js +5 -2
  129. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  130. package/build-module/components/global-styles/ui.js +4 -1
  131. package/build-module/components/global-styles/ui.js.map +1 -1
  132. package/build-module/components/global-styles/variations/variations-color.js +10 -3
  133. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  134. package/build-module/components/global-styles/variations/variations-typography.js +9 -2
  135. package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
  136. package/build-module/components/keyboard-shortcut-help-modal/index.js +3 -0
  137. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  138. package/build-module/components/layout/animation.js +122 -0
  139. package/build-module/components/layout/animation.js.map +1 -0
  140. package/build-module/components/layout/index.js +9 -17
  141. package/build-module/components/layout/index.js.map +1 -1
  142. package/build-module/components/layout/router.js +21 -18
  143. package/build-module/components/layout/router.js.map +1 -1
  144. package/build-module/components/page-pages/index.js +19 -17
  145. package/build-module/components/page-pages/index.js.map +1 -1
  146. package/build-module/components/page-patterns/index.js +20 -30
  147. package/build-module/components/page-patterns/index.js.map +1 -1
  148. package/build-module/components/page-patterns/search-items.js +14 -55
  149. package/build-module/components/page-patterns/search-items.js.map +1 -1
  150. package/build-module/components/page-templates-template-parts/actions.js +54 -40
  151. package/build-module/components/page-templates-template-parts/actions.js.map +1 -1
  152. package/build-module/components/page-templates-template-parts/index.js +29 -62
  153. package/build-module/components/page-templates-template-parts/index.js.map +1 -1
  154. package/build-module/components/plugin-template-setting-panel/index.js +12 -1
  155. package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
  156. package/build-module/components/save-button/index.js +46 -17
  157. package/build-module/components/save-button/index.js.map +1 -1
  158. package/build-module/components/save-hub/index.js +10 -114
  159. package/build-module/components/save-hub/index.js.map +1 -1
  160. package/build-module/components/sidebar/index.js +1 -5
  161. package/build-module/components/sidebar/index.js.map +1 -1
  162. package/build-module/components/sidebar-dataviews/default-views.js +1 -1
  163. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  164. package/build-module/components/sidebar-dataviews/index.js +1 -1
  165. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  166. package/build-module/components/sidebar-edit-mode/index.js +1 -2
  167. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  168. package/build-module/components/sidebar-edit-mode/page-panels/index.js +8 -18
  169. package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  170. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
  171. package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
  172. package/build-module/components/sidebar-edit-mode/template-panel/index.js +11 -17
  173. package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  174. package/build-module/components/sidebar-navigation-screen-details-footer/index.js +5 -1
  175. package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  176. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +10 -5
  177. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  178. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -5
  179. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  180. package/build-module/components/style-book/index.js +1 -1
  181. package/build-module/components/style-book/index.js.map +1 -1
  182. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  183. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  184. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  185. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  186. package/build-module/hooks/index.js +0 -1
  187. package/build-module/hooks/index.js.map +1 -1
  188. package/build-module/store/selectors.js +1 -9
  189. package/build-module/store/selectors.js.map +1 -1
  190. package/build-style/style-rtl.css +116 -104
  191. package/build-style/style.css +116 -104
  192. package/package.json +44 -44
  193. package/src/components/block-editor/editor-canvas.js +14 -2
  194. package/src/components/block-editor/site-editor-canvas.js +10 -7
  195. package/src/components/editor/index.js +11 -4
  196. package/src/components/editor-canvas-container/index.js +0 -1
  197. package/src/components/global-styles/background-panel.js +34 -0
  198. package/src/components/global-styles/font-families.js +1 -1
  199. package/src/components/global-styles/font-library-modal/context.js +43 -14
  200. package/src/components/global-styles/font-library-modal/style.scss +1 -1
  201. package/src/components/global-styles/font-library-modal/utils/index.js +17 -4
  202. package/src/components/global-styles/palette.js +3 -1
  203. package/src/components/global-styles/preview-colors.js +2 -2
  204. package/src/components/global-styles/root-menu.js +12 -1
  205. package/src/components/global-styles/screen-background.js +29 -0
  206. package/src/components/global-styles/screen-color-palette.js +2 -2
  207. package/src/components/global-styles/screen-colors.js +4 -4
  208. package/src/components/global-styles/screen-style-variations.js +4 -36
  209. package/src/components/global-styles/screen-typography.js +6 -9
  210. package/src/components/global-styles/style-variations-container.js +2 -1
  211. package/src/components/global-styles/style.scss +14 -12
  212. package/src/components/global-styles/ui.js +5 -0
  213. package/src/components/global-styles/variations/style.scss +32 -17
  214. package/src/components/global-styles/variations/variations-color.js +4 -2
  215. package/src/components/global-styles/variations/variations-typography.js +4 -1
  216. package/src/components/header-edit-mode/style.scss +28 -17
  217. package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
  218. package/src/components/layout/animation.js +122 -0
  219. package/src/components/layout/index.js +12 -27
  220. package/src/components/layout/router.js +25 -19
  221. package/src/components/layout/style.scss +2 -0
  222. package/src/components/page-pages/index.js +27 -43
  223. package/src/components/page-patterns/index.js +20 -28
  224. package/src/components/page-patterns/search-items.js +13 -58
  225. package/src/components/page-templates-template-parts/actions.js +106 -91
  226. package/src/components/page-templates-template-parts/index.js +34 -78
  227. package/src/components/page-templates-template-parts/style.scss +5 -0
  228. package/src/components/plugin-template-setting-panel/index.js +14 -1
  229. package/src/components/save-button/index.js +55 -26
  230. package/src/components/save-hub/index.js +20 -164
  231. package/src/components/sidebar/index.js +0 -5
  232. package/src/components/sidebar-dataviews/default-views.js +1 -1
  233. package/src/components/sidebar-dataviews/index.js +1 -1
  234. package/src/components/sidebar-edit-mode/index.js +0 -2
  235. package/src/components/sidebar-edit-mode/page-panels/index.js +29 -60
  236. package/src/components/sidebar-edit-mode/page-panels/page-content.js +10 -10
  237. package/src/components/sidebar-edit-mode/template-panel/index.js +23 -33
  238. package/src/components/sidebar-edit-mode/template-panel/style.scss +1 -29
  239. package/src/components/sidebar-navigation-screen/style.scss +12 -9
  240. package/src/components/sidebar-navigation-screen-details-footer/index.js +6 -2
  241. package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -13
  242. package/src/components/sidebar-navigation-screen-patterns/index.js +0 -7
  243. package/src/components/style-book/index.js +1 -3
  244. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
  245. package/src/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
  246. package/src/hooks/index.js +0 -1
  247. package/src/store/selectors.js +3 -15
  248. package/src/style.scss +0 -1
  249. package/build/components/actions/index.js +0 -319
  250. package/build/components/actions/index.js.map +0 -1
  251. package/build/components/sidebar-edit-mode/sidebar-card/index.js +0 -48
  252. package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
  253. package/build/components/sidebar-edit-mode/template-panel/template-areas.js +0 -70
  254. package/build/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
  255. package/build/components/sidebar-navigation-screen-pages/index.js +0 -175
  256. package/build/components/sidebar-navigation-screen-pages/index.js.map +0 -1
  257. package/build/hooks/template-part-edit.js +0 -82
  258. package/build/hooks/template-part-edit.js.map +0 -1
  259. package/build/store/utils.js +0 -71
  260. package/build/store/utils.js.map +0 -1
  261. package/build-module/components/actions/index.js +0 -308
  262. package/build-module/components/actions/index.js.map +0 -1
  263. package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +0 -40
  264. package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
  265. package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js +0 -63
  266. package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
  267. package/build-module/components/sidebar-navigation-screen-pages/index.js +0 -167
  268. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +0 -1
  269. package/build-module/hooks/template-part-edit.js +0 -75
  270. package/build-module/hooks/template-part-edit.js.map +0 -1
  271. package/build-module/store/utils.js +0 -64
  272. package/build-module/store/utils.js.map +0 -1
  273. package/src/components/actions/index.js +0 -409
  274. package/src/components/sidebar-edit-mode/sidebar-card/index.js +0 -53
  275. package/src/components/sidebar-edit-mode/sidebar-card/style.scss +0 -36
  276. package/src/components/sidebar-edit-mode/template-panel/template-areas.js +0 -86
  277. package/src/components/sidebar-navigation-screen-pages/index.js +0 -238
  278. package/src/hooks/template-part-edit.js +0 -89
  279. package/src/store/test/utils.js +0 -191
  280. package/src/store/utils.js +0 -69
@@ -0,0 +1,34 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { unlock } from '../../lock-unlock';
10
+
11
+ const {
12
+ useGlobalStyle,
13
+ useGlobalSetting,
14
+ BackgroundPanel: StylesBackgroundPanel,
15
+ } = unlock( blockEditorPrivateApis );
16
+
17
+ export default function BackgroundPanel() {
18
+ const [ style ] = useGlobalStyle( '', undefined, 'user', {
19
+ shouldDecodeEncode: false,
20
+ } );
21
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( '', undefined, 'all', {
22
+ shouldDecodeEncode: false,
23
+ } );
24
+ const [ settings ] = useGlobalSetting( '' );
25
+
26
+ return (
27
+ <StylesBackgroundPanel
28
+ inheritedValue={ inheritedStyle }
29
+ value={ style }
30
+ onChange={ setStyle }
31
+ settings={ settings }
32
+ />
33
+ );
34
+ }
@@ -37,7 +37,7 @@ function FontFamilies() {
37
37
  />
38
38
  ) }
39
39
 
40
- <VStack spacing={ 3 }>
40
+ <VStack spacing={ 2 }>
41
41
  <HStack justify="space-between">
42
42
  <Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
43
43
  <HStack justify="flex-end">
@@ -105,18 +105,31 @@ function FontLibraryProvider( { children } ) {
105
105
  const [ modalTabOpen, setModalTabOpen ] = useState( false );
106
106
  const [ libraryFontSelected, setLibraryFontSelected ] = useState( null );
107
107
 
108
- const baseThemeFonts = baseFontFamilies?.theme
109
- ? baseFontFamilies.theme
110
- .map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )
111
- .sort( ( a, b ) => a.name.localeCompare( b.name ) )
112
- : [];
113
-
108
+ // Themes Fonts are the fonts defined in the global styles (database persisted theme.json data).
114
109
  const themeFonts = fontFamilies?.theme
115
110
  ? fontFamilies.theme
116
111
  .map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )
117
112
  .sort( ( a, b ) => a.name.localeCompare( b.name ) )
118
113
  : [];
119
114
 
115
+ const themeFontsSlugs = new Set( themeFonts.map( ( f ) => f.slug ) );
116
+
117
+ /*
118
+ * Base Theme Fonts are the fonts defined in the theme.json *file*.
119
+ *
120
+ * Uses the fonts from global styles + the ones from the theme.json file that hasn't repeated slugs.
121
+ * Avoids incosistencies with the fonts listed in the font library modal as base (unactivated).
122
+ * These inconsistencies can happen when the active theme fonts in global styles aren't defined in theme.json file as when a theme style variation is applied.
123
+ */
124
+ const baseThemeFonts = baseFontFamilies?.theme
125
+ ? themeFonts.concat(
126
+ baseFontFamilies.theme
127
+ .filter( ( f ) => ! themeFontsSlugs.has( f.slug ) )
128
+ .map( ( f ) => setUIValuesNeeded( f, { source: 'theme' } ) )
129
+ .sort( ( a, b ) => a.name.localeCompare( b.name ) )
130
+ )
131
+ : [];
132
+
120
133
  const customFonts = fontFamilies?.custom
121
134
  ? fontFamilies.custom
122
135
  .map( ( f ) => setUIValuesNeeded( f, { source: 'custom' } ) )
@@ -144,8 +157,7 @@ function FontLibraryProvider( { children } ) {
144
157
  return;
145
158
  }
146
159
 
147
- const fonts =
148
- font.source === 'theme' ? baseThemeFonts : baseCustomFonts;
160
+ const fonts = font.source === 'theme' ? themeFonts : baseCustomFonts;
149
161
 
150
162
  // Tries to find the font in the installed fonts
151
163
  const fontSelected = fonts.find( ( f ) => f.slug === font.slug );
@@ -269,11 +281,13 @@ function FontLibraryProvider( { children } ) {
269
281
  sucessfullyInstalledFontFaces?.length > 0 ||
270
282
  alreadyInstalledFontFaces?.length > 0
271
283
  ) {
272
- fontFamilyToInstall.fontFace = [
284
+ // Use font data from REST API not from client to ensure
285
+ // correct font information is used.
286
+ installedFontFamily.fontFace = [
273
287
  ...sucessfullyInstalledFontFaces,
274
- ...alreadyInstalledFontFaces,
275
288
  ];
276
- fontFamiliesToActivate.push( fontFamilyToInstall );
289
+
290
+ fontFamiliesToActivate.push( installedFontFamily );
277
291
  }
278
292
 
279
293
  // If it's a system font but was installed successfully, activate it.
@@ -390,14 +404,29 @@ function FontLibraryProvider( { children } ) {
390
404
  };
391
405
 
392
406
  const activateCustomFontFamilies = ( fontsToAdd ) => {
393
- // Merge the existing custom fonts with the new fonts.
407
+ // Removes the id from the families and faces to avoid saving that to global styles post content.
408
+ const fontsToActivate = fontsToAdd.map(
409
+ ( { id: _familyDbId, fontFace, ...font } ) => ( {
410
+ ...font,
411
+ ...( fontFace && fontFace.length > 0
412
+ ? {
413
+ fontFace: fontFace.map(
414
+ ( { id: _faceDbId, ...face } ) => face
415
+ ),
416
+ }
417
+ : {} ),
418
+ } )
419
+ );
420
+
394
421
  // Activate the fonts by set the new custom fonts array.
395
422
  setFontFamilies( {
396
423
  ...fontFamilies,
397
- custom: mergeFontFamilies( fontFamilies?.custom, fontsToAdd ),
424
+ // Merge the existing custom fonts with the new fonts.
425
+ custom: mergeFontFamilies( fontFamilies?.custom, fontsToActivate ),
398
426
  } );
427
+
399
428
  // Add custom fonts to the browser.
400
- fontsToAdd.forEach( ( font ) => {
429
+ fontsToActivate.forEach( ( font ) => {
401
430
  if ( font.fontFace ) {
402
431
  font.fontFace.forEach( ( face ) => {
403
432
  // Load font faces just in the iframe because they already are in the document.
@@ -1,5 +1,5 @@
1
1
  .font-library-modal {
2
- // @todo: If a new prop is added to the Modal component that constrains
2
+ // @todo If a new prop is added to the Modal component that constrains
3
3
  // the content width, we should use that prop instead of this style.
4
4
  // see https://github.com/WordPress/gutenberg/issues/54471.
5
5
  &.font-library-modal {
@@ -234,10 +234,23 @@ export function makeFontFacesFormData( font ) {
234
234
  }
235
235
 
236
236
  export async function batchInstallFontFaces( fontFamilyId, fontFacesData ) {
237
- const promises = fontFacesData.map( ( faceData ) =>
238
- fetchInstallFontFace( fontFamilyId, faceData )
239
- );
240
- const responses = await Promise.allSettled( promises );
237
+ const responses = [];
238
+
239
+ /*
240
+ * Uses the same response format as Promise.allSettled, but executes requests in sequence to work
241
+ * around a race condition that can cause an error when the fonts directory doesn't exist yet.
242
+ */
243
+ for ( const faceData of fontFacesData ) {
244
+ try {
245
+ const response = await fetchInstallFontFace(
246
+ fontFamilyId,
247
+ faceData
248
+ );
249
+ responses.push( { status: 'fulfilled', value: response } );
250
+ } catch ( error ) {
251
+ responses.push( { status: 'rejected', reason: error } );
252
+ }
253
+ }
241
254
 
242
255
  const results = {
243
256
  errors: [],
@@ -87,7 +87,9 @@ function Palette( { name } ) {
87
87
  </ColorIndicatorWrapper>
88
88
  ) ) }
89
89
  </ZStack>
90
- <FlexItem>{ paletteButtonText }</FlexItem>
90
+ <FlexItem className="edit-site-global-styles-screen-colors__palette-count">
91
+ { paletteButtonText }
92
+ </FlexItem>
91
93
  </HStack>
92
94
  </NavigationButtonAsItem>
93
95
  </ItemGroup>
@@ -40,7 +40,7 @@ const StylesPreviewColors = ( { label, isFocused, withHoverView } ) => {
40
40
  } }
41
41
  >
42
42
  <HStack
43
- spacing={ 10 * ratio }
43
+ spacing={ 5 * ratio }
44
44
  justify="center"
45
45
  style={ {
46
46
  height: '100%',
@@ -48,7 +48,7 @@ const StylesPreviewColors = ( { label, isFocused, withHoverView } ) => {
48
48
  } }
49
49
  >
50
50
  <HighlightedColors
51
- normalizedColorSwatchSize={ 66 }
51
+ normalizedColorSwatchSize={ 56 }
52
52
  ratio={ ratio }
53
53
  />
54
54
  </HStack>
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
5
- import { typography, color, layout } from '@wordpress/icons';
5
+ import { typography, color, layout, image } from '@wordpress/icons';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
8
8
 
@@ -18,6 +18,7 @@ const {
18
18
  useHasColorPanel,
19
19
  useGlobalSetting,
20
20
  useSettingsForBlockElement,
21
+ useHasBackgroundPanel,
21
22
  } = unlock( blockEditorPrivateApis );
22
23
 
23
24
  function RootMenu() {
@@ -27,6 +28,7 @@ function RootMenu() {
27
28
  const hasColorPanel = useHasColorPanel( settings );
28
29
  const hasDimensionsPanel = useHasDimensionsPanel( settings );
29
30
  const hasLayoutPanel = hasDimensionsPanel;
31
+ const hasBackgroundPanel = useHasBackgroundPanel( settings );
30
32
 
31
33
  return (
32
34
  <>
@@ -58,6 +60,15 @@ function RootMenu() {
58
60
  { __( 'Layout' ) }
59
61
  </NavigationButtonAsItem>
60
62
  ) }
63
+ { hasBackgroundPanel && (
64
+ <NavigationButtonAsItem
65
+ icon={ image }
66
+ path="/background"
67
+ aria-label={ __( 'Background styles' ) }
68
+ >
69
+ { __( 'Background' ) }
70
+ </NavigationButtonAsItem>
71
+ ) }
61
72
  </ItemGroup>
62
73
  </>
63
74
  );
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import BackgroundPanel from './background-panel';
11
+ import ScreenHeader from './header';
12
+ import { unlock } from '../../lock-unlock';
13
+
14
+ const { useHasBackgroundPanel, useGlobalSetting } = unlock(
15
+ blockEditorPrivateApis
16
+ );
17
+
18
+ function ScreenBackground() {
19
+ const [ settings ] = useGlobalSetting( '' );
20
+ const hasBackgroundPanel = useHasBackgroundPanel( settings );
21
+ return (
22
+ <>
23
+ <ScreenHeader title={ __( 'Background' ) } />
24
+ { hasBackgroundPanel && <BackgroundPanel /> }
25
+ </>
26
+ );
27
+ }
28
+
29
+ export default ScreenBackground;
@@ -25,8 +25,8 @@ function ScreenColorPalette( { name } ) {
25
25
  />
26
26
  <Tabs>
27
27
  <Tabs.TabList>
28
- <Tabs.Tab tabId="solid">Solid</Tabs.Tab>
29
- <Tabs.Tab tabId="gradient">Gradient</Tabs.Tab>
28
+ <Tabs.Tab tabId="solid">{ __( 'Solid' ) }</Tabs.Tab>
29
+ <Tabs.Tab tabId="gradient">{ __( 'Gradient' ) }</Tabs.Tab>
30
30
  </Tabs.TabList>
31
31
  <Tabs.TabPanel tabId="solid" focusable={ false }>
32
32
  <ColorPalettePanel name={ name } />
@@ -35,12 +35,12 @@ function ScreenColors() {
35
35
  <ScreenHeader
36
36
  title={ __( 'Colors' ) }
37
37
  description={ __(
38
- 'Manage palettes and the default color of different global elements on the site.'
38
+ 'Palette colors and the application of those colors on site elements.'
39
39
  ) }
40
40
  />
41
- <div className="edit-site-global-styles-screen-colors">
42
- <VStack spacing={ 6 }>
43
- <ColorVariations />
41
+ <div className="edit-site-global-styles-screen">
42
+ <VStack spacing={ 7 }>
43
+ <ColorVariations title={ __( 'Presets' ) } />
44
44
  <Palette />
45
45
  <StylesColorPanel
46
46
  inheritedValue={ inheritedStyle }
@@ -3,9 +3,7 @@
3
3
  */
4
4
  import { Card, CardBody } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
- import { store as blockEditorStore } from '@wordpress/block-editor';
7
- import { useEffect, useRef } from '@wordpress/element';
8
- import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { useZoomOut } from '@wordpress/block-editor';
9
7
 
10
8
  /**
11
9
  * Internal dependencies
@@ -14,43 +12,13 @@ import ScreenHeader from './header';
14
12
  import StyleVariationsContainer from './style-variations-container';
15
13
 
16
14
  function ScreenStyleVariations() {
17
- const { mode } = useSelect( ( select ) => {
18
- return {
19
- mode: select( blockEditorStore ).__unstableGetEditorMode(),
20
- };
21
- }, [] );
22
-
23
- const shouldRevertInitialMode = useRef( null );
24
- useEffect( () => {
25
- // ignore changes to zoom-out mode as we explictily change to it on mount.
26
- if ( mode !== 'zoom-out' ) {
27
- shouldRevertInitialMode.current = false;
28
- }
29
- }, [ mode ] );
30
-
31
- // Intentionality left without any dependency.
32
- // This effect should only run the first time the component is rendered.
33
- // The effect opens the zoom-out view if it is not open before when applying a style variation.
34
- useEffect( () => {
35
- if ( mode !== 'zoom-out' ) {
36
- __unstableSetEditorMode( 'zoom-out' );
37
- shouldRevertInitialMode.current = true;
38
- return () => {
39
- // if there were not mode changes revert to the initial mode when unmounting.
40
- if ( shouldRevertInitialMode.current ) {
41
- __unstableSetEditorMode( mode );
42
- }
43
- };
44
- }
45
- // eslint-disable-next-line react-hooks/exhaustive-deps
46
- }, [] );
47
-
48
- const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
15
+ // Move to zoom out mode when this component is mounted
16
+ // and back to the previous mode when unmounted.
17
+ useZoomOut();
49
18
 
50
19
  return (
51
20
  <>
52
21
  <ScreenHeader
53
- back="/"
54
22
  title={ __( 'Browse styles' ) }
55
23
  description={ __(
56
24
  'Choose a variation to change the look of the site.'
@@ -26,17 +26,14 @@ function ScreenTypography() {
26
26
  <ScreenHeader
27
27
  title={ __( 'Typography' ) }
28
28
  description={ __(
29
- 'Manage the typography settings for different elements.'
29
+ 'Typography styles and the application of those styles on site elements.'
30
30
  ) }
31
31
  />
32
- <div className="edit-site-global-styles-screen-typography">
33
- <VStack spacing={ 6 }>
34
- <TypographyVariations />
35
- { ! window.__experimentalDisableFontLibrary && (
36
- <VStack spacing={ 3 }>
37
- { fontLibraryEnabled && <FontFamilies /> }
38
- </VStack>
39
- ) }
32
+ <div className="edit-site-global-styles-screen">
33
+ <VStack spacing={ 7 }>
34
+ <TypographyVariations title={ __( 'Presets' ) } />
35
+ { ! window.__experimentalDisableFontLibrary &&
36
+ fontLibraryEnabled && <FontFamilies /> }
40
37
  <TypographyElements />
41
38
  </VStack>
42
39
  </div>
@@ -13,7 +13,7 @@ import { __ } from '@wordpress/i18n';
13
13
  import PreviewStyles from './preview-styles';
14
14
  import Variation from './variations/variation';
15
15
 
16
- export default function StyleVariationsContainer() {
16
+ export default function StyleVariationsContainer( { gap = 2 } ) {
17
17
  const variations = useSelect( ( select ) => {
18
18
  return select(
19
19
  coreStore
@@ -39,6 +39,7 @@ export default function StyleVariationsContainer() {
39
39
  <Grid
40
40
  columns={ 2 }
41
41
  className="edit-site-global-styles-style-variations-container"
42
+ gap={ gap }
42
43
  >
43
44
  { withEmptyVariation.map( ( variation, index ) => (
44
45
  <Variation key={ index } variation={ variation }>
@@ -7,9 +7,9 @@
7
7
  }
8
8
 
9
9
  .edit-site-global-styles-preview__iframe {
10
- border-radius: $radius-block-ui;
11
- display: block;
10
+ border-radius: $radius-block-ui + 1px; // Visually resembles the $radius-block-ui.
12
11
  max-width: 100%;
12
+ display: block;
13
13
  width: 100%;
14
14
  }
15
15
 
@@ -29,9 +29,8 @@
29
29
  max-width: 100%;
30
30
  }
31
31
 
32
- .edit-site-global-styles-screen-typography,
33
- .edit-site-global-styles-screen-css {
34
- margin: $grid-unit-20;
32
+ .edit-site-global-styles-screen {
33
+ margin: $grid-unit-15 $grid-unit-20 $grid-unit-20;
35
34
  }
36
35
 
37
36
  .edit-site-global-styles-screen-typography__indicator {
@@ -52,14 +51,16 @@
52
51
  justify-content: center;
53
52
  }
54
53
 
55
- .edit-site-global-styles-screen-colors {
56
- margin: $grid-unit-20;
54
+ .edit-site-global-styles-screen .color-block-support-panel {
55
+ padding-left: 0;
56
+ padding-right: 0;
57
+ padding-top: 0;
58
+ border-top: none;
59
+ row-gap: calc(#{$grid-unit-05} * 3);
60
+ }
57
61
 
58
- .color-block-support-panel {
59
- padding-left: 0;
60
- padding-right: 0;
61
- border-top: none;
62
- }
62
+ .edit-site-global-styles-screen-colors__palette-count {
63
+ color: $gray-700;
63
64
  }
64
65
 
65
66
  .edit-site-global-styles-header__description {
@@ -115,6 +116,7 @@
115
116
  flex: 1 1 auto;
116
117
  display: flex;
117
118
  flex-direction: column;
119
+ margin: $grid-unit-20;
118
120
 
119
121
  .components-v-stack {
120
122
  flex: 1 1 auto;
@@ -40,6 +40,7 @@ import ScreenStyleVariations from './screen-style-variations';
40
40
  import StyleBook from '../style-book';
41
41
  import ScreenCSS from './screen-css';
42
42
  import ScreenRevisions from './screen-revisions';
43
+ import ScreenBackground from './screen-background';
43
44
  import { unlock } from '../../lock-unlock';
44
45
  import { store as editSiteStore } from '../../store';
45
46
 
@@ -344,6 +345,10 @@ function GlobalStylesUI() {
344
345
  <ScreenRevisions />
345
346
  </GlobalStylesNavigationScreen>
346
347
 
348
+ <GlobalStylesNavigationScreen path={ '/background' }>
349
+ <ScreenBackground />
350
+ </GlobalStylesNavigationScreen>
351
+
347
352
  { blocks.map( ( block ) => (
348
353
  <GlobalStylesNavigationScreen
349
354
  key={ 'menu-block-' + block.name }
@@ -5,34 +5,49 @@
5
5
  cursor: pointer;
6
6
 
7
7
  .edit-site-global-styles-variations_item-preview {
8
- padding: $border-width * 2;
9
8
  border-radius: $radius-block-ui;
10
- box-shadow: 0 0 0 $border-width $gray-200;
11
9
  // Shown in Windows 10 high contrast mode.
12
10
  outline: 1px solid transparent;
11
+ position: relative;
12
+ // Add the same transition that block style variations and other buttons have.
13
+ transition: box-shadow 0.1s linear;
14
+ @include reduce-motion("transition");
15
+
16
+ &::after {
17
+ content: "";
18
+ position: absolute;
19
+ top: -$border-width;
20
+ left: -$border-width;
21
+ bottom: -$border-width;
22
+ right: -$border-width;
23
+ // Visually resembles the $radius-block-ui.
24
+ border-radius: $radius-block-ui + $border-width;
25
+ box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
26
+ // Show a thin outline in Windows high contrast mode, otherwise the button is invisible.
27
+ border: $border-width solid transparent;
28
+ box-sizing: inherit;
29
+ // Add the same transition that block style variations and other buttons have.
30
+ transition: box-shadow 0.1s linear;
31
+ @include reduce-motion("transition");
32
+ }
13
33
 
14
34
  .edit-site-global-styles-color-variations & {
15
35
  padding: $grid-unit-10;
16
36
  }
17
37
  }
18
38
 
19
- &.is-active .edit-site-global-styles-variations_item-preview {
20
- box-shadow: 0 0 0 $border-width $gray-900;
21
- // Shown in Windows 10 high contrast mode.
22
- outline-width: 3px;
23
- }
24
-
25
- &:hover .edit-site-global-styles-variations_item-preview {
26
- box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
39
+ &:not(.is-active):hover .edit-site-global-styles-variations_item-preview::after {
40
+ box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.4);
27
41
  }
28
42
 
29
- &:focus .edit-site-global-styles-variations_item-preview {
30
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
31
- }
32
-
33
- &:focus-visible {
43
+ &.is-active .edit-site-global-styles-variations_item-preview,
44
+ &:focus-visible .edit-site-global-styles-variations_item-preview {
45
+ box-shadow: inset 0 0 0 $border-width $white, 0 0 0 var(--wp-admin-border-width-focus) $gray-900;
34
46
  // Shown in Windows 10 high contrast mode.
35
- outline: 3px solid transparent;
36
- outline-offset: 0;
47
+ outline-width: 3px;
48
+
49
+ &::after {
50
+ box-shadow: inset 0 0 0 1px $white;
51
+ }
37
52
  }
38
53
  }
@@ -12,8 +12,9 @@ import {
12
12
  import Variation from './variation';
13
13
  import StylesPreviewColors from '../preview-colors';
14
14
  import { useColorVariations } from '../hooks';
15
+ import Subtitle from '../subtitle';
15
16
 
16
- export default function ColorVariations() {
17
+ export default function ColorVariations( { title, gap = 2 } ) {
17
18
  const colorVariations = useColorVariations();
18
19
 
19
20
  if ( ! colorVariations?.length ) {
@@ -22,7 +23,8 @@ export default function ColorVariations() {
22
23
 
23
24
  return (
24
25
  <VStack spacing={ 3 }>
25
- <Grid columns={ 3 }>
26
+ { title && <Subtitle level={ 3 }>{ title }</Subtitle> }
27
+ <Grid columns={ 3 } gap={ gap }>
26
28
  { colorVariations.map( ( variation, index ) => (
27
29
  <Variation key={ index } variation={ variation }>
28
30
  { () => <StylesPreviewColors /> }
@@ -14,8 +14,9 @@ import { useTypographyVariations } from '../hooks';
14
14
  import TypographyExample from '../typography-example';
15
15
  import PreviewIframe from '../preview-iframe';
16
16
  import Variation from './variation';
17
+ import Subtitle from '../subtitle';
17
18
 
18
- export default function TypographyVariations() {
19
+ export default function TypographyVariations( { title, gap = 2 } ) {
19
20
  const typographyVariations = useTypographyVariations();
20
21
 
21
22
  if ( ! typographyVariations?.length ) {
@@ -24,8 +25,10 @@ export default function TypographyVariations() {
24
25
 
25
26
  return (
26
27
  <VStack spacing={ 3 }>
28
+ { title && <Subtitle level={ 3 }>{ title }</Subtitle> }
27
29
  <Grid
28
30
  columns={ 3 }
31
+ gap={ gap }
29
32
  className="edit-site-global-styles-style-variations-container"
30
33
  >
31
34
  { typographyVariations &&