@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.
- package/build/components/dataviews-actions/index.js +1 -1
- package/build/components/dataviews-actions/index.js.map +2 -2
- package/build/components/global-styles-renderer/index.js +2 -4
- package/build/components/global-styles-renderer/index.js.map +3 -3
- package/build/components/page-templates/fields.js +13 -2
- package/build/components/page-templates/fields.js.map +2 -2
- package/build/components/page-templates/index.js +7 -3
- package/build/components/page-templates/index.js.map +2 -2
- package/build/components/revisions/index.js +2 -2
- package/build/components/revisions/index.js.map +2 -2
- package/build/components/style-book/index.js +24 -19
- package/build/components/style-book/index.js.map +2 -2
- package/build/hooks/use-global-styles-output.js +77 -0
- package/build/hooks/use-global-styles-output.js.map +7 -0
- package/build-module/components/dataviews-actions/index.js +1 -1
- package/build-module/components/dataviews-actions/index.js.map +2 -2
- package/build-module/components/global-styles-renderer/index.js +1 -3
- package/build-module/components/global-styles-renderer/index.js.map +2 -2
- package/build-module/components/page-templates/fields.js +14 -3
- package/build-module/components/page-templates/fields.js.map +2 -2
- package/build-module/components/page-templates/index.js +7 -3
- package/build-module/components/page-templates/index.js.map +2 -2
- package/build-module/components/revisions/index.js +1 -1
- package/build-module/components/revisions/index.js.map +2 -2
- package/build-module/components/style-book/index.js +22 -17
- package/build-module/components/style-book/index.js.map +2 -2
- package/build-module/hooks/use-global-styles-output.js +52 -0
- package/build-module/hooks/use-global-styles-output.js.map +7 -0
- package/build-style/posts-rtl.css +15 -16
- package/build-style/posts.css +15 -16
- package/build-style/style-rtl.css +25 -26
- package/build-style/style.css +25 -26
- package/package.json +45 -44
- package/src/components/dataviews-actions/index.js +1 -0
- package/src/components/global-styles/font-library-modal/style.scss +3 -3
- package/src/components/global-styles/style.scss +1 -1
- package/src/components/global-styles-renderer/index.js +1 -4
- package/src/components/global-styles-sidebar/style.scss +2 -2
- package/src/components/page-templates/fields.js +15 -6
- package/src/components/page-templates/index.js +19 -9
- package/src/components/revisions/index.js +1 -1
- package/src/components/sidebar-navigation-screen/style.scss +1 -1
- package/src/components/sidebar-navigation-screen-patterns/style.scss +1 -1
- package/src/components/site-hub/style.scss +1 -1
- package/src/components/style-book/index.js +26 -19
- package/src/hooks/use-global-styles-output.js +80 -0
- 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 );
|
|
@@ -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
|
-
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
+
}
|