@wordpress/edit-site 6.33.1 → 6.33.3-next.36001005c.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 (47) hide show
  1. package/build/components/dataviews-actions/index.js +1 -1
  2. package/build/components/dataviews-actions/index.js.map +2 -2
  3. package/build/components/global-styles-renderer/index.js +2 -4
  4. package/build/components/global-styles-renderer/index.js.map +3 -3
  5. package/build/components/page-templates/fields.js +13 -2
  6. package/build/components/page-templates/fields.js.map +2 -2
  7. package/build/components/page-templates/index.js +7 -3
  8. package/build/components/page-templates/index.js.map +2 -2
  9. package/build/components/revisions/index.js +2 -2
  10. package/build/components/revisions/index.js.map +2 -2
  11. package/build/components/style-book/index.js +24 -19
  12. package/build/components/style-book/index.js.map +2 -2
  13. package/build/hooks/use-global-styles-output.js +77 -0
  14. package/build/hooks/use-global-styles-output.js.map +7 -0
  15. package/build-module/components/dataviews-actions/index.js +1 -1
  16. package/build-module/components/dataviews-actions/index.js.map +2 -2
  17. package/build-module/components/global-styles-renderer/index.js +1 -3
  18. package/build-module/components/global-styles-renderer/index.js.map +2 -2
  19. package/build-module/components/page-templates/fields.js +14 -3
  20. package/build-module/components/page-templates/fields.js.map +2 -2
  21. package/build-module/components/page-templates/index.js +7 -3
  22. package/build-module/components/page-templates/index.js.map +2 -2
  23. package/build-module/components/revisions/index.js +1 -1
  24. package/build-module/components/revisions/index.js.map +2 -2
  25. package/build-module/components/style-book/index.js +22 -17
  26. package/build-module/components/style-book/index.js.map +2 -2
  27. package/build-module/hooks/use-global-styles-output.js +52 -0
  28. package/build-module/hooks/use-global-styles-output.js.map +7 -0
  29. package/build-style/posts-rtl.css +15 -16
  30. package/build-style/posts.css +15 -16
  31. package/build-style/style-rtl.css +25 -26
  32. package/build-style/style.css +25 -26
  33. package/package.json +45 -44
  34. package/src/components/dataviews-actions/index.js +1 -0
  35. package/src/components/global-styles/font-library-modal/style.scss +3 -3
  36. package/src/components/global-styles/style.scss +1 -1
  37. package/src/components/global-styles-renderer/index.js +1 -4
  38. package/src/components/global-styles-sidebar/style.scss +2 -2
  39. package/src/components/page-templates/fields.js +15 -6
  40. package/src/components/page-templates/index.js +19 -9
  41. package/src/components/revisions/index.js +1 -1
  42. package/src/components/sidebar-navigation-screen/style.scss +1 -1
  43. package/src/components/sidebar-navigation-screen-patterns/style.scss +1 -1
  44. package/src/components/site-hub/style.scss +1 -1
  45. package/src/components/style-book/index.js +26 -19
  46. package/src/hooks/use-global-styles-output.js +80 -0
  47. package/tsconfig.json +1 -0
@@ -20,11 +20,11 @@ import { useContext, useMemo } from '@wordpress/element';
20
20
 
21
21
  import { unlock } from '../../lock-unlock';
22
22
  import EditorCanvasContainer from '../editor-canvas-container';
23
+ import { useGlobalStylesOutputWithConfig } from '../../hooks/use-global-styles-output';
23
24
 
24
25
  const {
25
26
  ExperimentalBlockEditorProvider,
26
27
  GlobalStylesContext,
27
- useGlobalStylesOutputWithConfig,
28
28
  __unstableBlockStyleVariationOverridesWithConfig,
29
29
  } = unlock( blockEditorPrivateApis );
30
30
  const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
@@ -76,7 +76,7 @@
76
76
  color: $gray-300;
77
77
  font-size: 11px;
78
78
  text-transform: uppercase;
79
- font-weight: 500;
79
+ font-weight: $font-weight-medium;
80
80
  }
81
81
 
82
82
  .edit-site-sidebar-navigation-screen__content .edit-site-global-styles-variations_item {
@@ -22,7 +22,7 @@
22
22
 
23
23
  h2 {
24
24
  font-size: 11px;
25
- font-weight: 500;
25
+ font-weight: $font-weight-medium;
26
26
  text-transform: uppercase;
27
27
  }
28
28
  }
@@ -29,7 +29,7 @@
29
29
  display: block;
30
30
  flex-grow: 1;
31
31
  font-size: 15px;
32
- font-weight: 500;
32
+ font-weight: $font-weight-medium;
33
33
  overflow: hidden;
34
34
  // Add space for the ↗ to render.
35
35
  padding-right: $grid-unit-20;
@@ -56,13 +56,10 @@ import {
56
56
  STYLE_BOOK_COLOR_GROUPS,
57
57
  STYLE_BOOK_PREVIEW_CATEGORIES,
58
58
  } from '../style-book/constants';
59
+ import { useGlobalStylesOutputWithConfig } from '../../hooks/use-global-styles-output';
59
60
 
60
- const {
61
- ExperimentalBlockEditorProvider,
62
- useGlobalStyle,
63
- GlobalStylesContext,
64
- useGlobalStylesOutputWithConfig,
65
- } = unlock( blockEditorPrivateApis );
61
+ const { ExperimentalBlockEditorProvider, useGlobalStyle, GlobalStylesContext } =
62
+ unlock( blockEditorPrivateApis );
66
63
  const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
67
64
 
68
65
  const { Tabs } = unlock( componentsPrivateApis );
@@ -227,19 +224,29 @@ function applyBlockVariationsToExamples( examples, variation ) {
227
224
  if ( ! variation ) {
228
225
  return examples;
229
226
  }
230
-
231
- return examples.map( ( example ) => ( {
232
- ...example,
233
- variation,
234
- blocks: {
235
- ...example.blocks,
236
- attributes: {
237
- ...example.blocks.attributes,
238
- style: undefined,
239
- className: getVariationClassName( variation ),
240
- },
241
- },
242
- } ) );
227
+ return examples.map( ( example ) => {
228
+ return {
229
+ ...example,
230
+ variation,
231
+ blocks: Array.isArray( example.blocks )
232
+ ? example.blocks.map( ( block ) => ( {
233
+ ...block,
234
+ attributes: {
235
+ ...block.attributes,
236
+ style: undefined,
237
+ className: getVariationClassName( variation ),
238
+ },
239
+ } ) )
240
+ : {
241
+ ...example.blocks,
242
+ attributes: {
243
+ ...example.blocks.attributes,
244
+ style: undefined,
245
+ className: getVariationClassName( variation ),
246
+ },
247
+ },
248
+ };
249
+ } );
243
250
  }
244
251
 
245
252
  function StyleBook( {
@@ -0,0 +1,80 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { getBlockTypes, store as blocksStore } from '@wordpress/blocks';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useContext, useMemo } from '@wordpress/element';
7
+ import { generateGlobalStyles } from '@wordpress/global-styles-engine';
8
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { store as editSiteStore } from '../store';
14
+ import { unlock } from '../lock-unlock';
15
+
16
+ const { GlobalStylesContext, useGlobalSetting } = unlock(
17
+ blockEditorPrivateApis
18
+ );
19
+
20
+ /**
21
+ * Returns the global styles output based on the provided global styles config.
22
+ *
23
+ * @param {Object} mergedConfig The merged global styles config.
24
+ * @param {boolean} disableRootPadding Disable root padding styles.
25
+ *
26
+ * @return {Array} Array of stylesheets and settings.
27
+ */
28
+ export function useGlobalStylesOutputWithConfig(
29
+ mergedConfig = {},
30
+ disableRootPadding = false
31
+ ) {
32
+ const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );
33
+ const hasBlockGapSupport = blockGap !== null;
34
+ const hasFallbackGapSupport = ! hasBlockGapSupport;
35
+
36
+ const { disableLayoutStyles, getBlockStyles } = useSelect( ( select ) => {
37
+ const { getSettings } = select( editSiteStore );
38
+ const { getBlockStyles: getBlockStylesSelector } =
39
+ select( blocksStore );
40
+ return {
41
+ disableLayoutStyles: !! getSettings()?.disableLayoutStyles,
42
+ getBlockStyles: getBlockStylesSelector,
43
+ };
44
+ }, [] );
45
+
46
+ return useMemo( () => {
47
+ if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
48
+ return [ [], {} ];
49
+ }
50
+
51
+ const blockTypes = getBlockTypes();
52
+
53
+ return generateGlobalStyles( mergedConfig, blockTypes, {
54
+ hasBlockGapSupport,
55
+ hasFallbackGapSupport,
56
+ disableLayoutStyles,
57
+ disableRootPadding,
58
+ getBlockStyles,
59
+ } );
60
+ }, [
61
+ hasBlockGapSupport,
62
+ hasFallbackGapSupport,
63
+ mergedConfig,
64
+ disableLayoutStyles,
65
+ disableRootPadding,
66
+ getBlockStyles,
67
+ ] );
68
+ }
69
+
70
+ /**
71
+ * Returns the global styles output based on the current state of global styles config loaded in the editor context.
72
+ *
73
+ * @param {boolean} disableRootPadding Disable root padding styles.
74
+ *
75
+ * @return {Array} Array of stylesheets and settings.
76
+ */
77
+ export function useGlobalStylesOutput( disableRootPadding = false ) {
78
+ const { merged: mergedConfig } = useContext( GlobalStylesContext );
79
+ return useGlobalStylesOutputWithConfig( mergedConfig, disableRootPadding );
80
+ }
package/tsconfig.json CHANGED
@@ -21,6 +21,7 @@
21
21
  { "path": "../element" },
22
22
  { "path": "../escape-html" },
23
23
  { "path": "../fields" },
24
+ { "path": "../global-styles-engine" },
24
25
  { "path": "../hooks" },
25
26
  { "path": "../html-entities" },
26
27
  { "path": "../i18n" },