@wordpress/block-editor 15.6.1 → 15.7.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/CHANGELOG.md +2 -0
- package/build/components/background-image-control/index.js +2 -2
- package/build/components/background-image-control/index.js.map +2 -2
- package/build/components/block-quick-navigation/index.js +1 -0
- package/build/components/block-quick-navigation/index.js.map +2 -2
- package/build/components/block-toolbar/switch-section-style.js +2 -5
- package/build/components/block-toolbar/switch-section-style.js.map +2 -2
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +3 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +0 -179
- package/build/components/global-styles/hooks.js.map +3 -3
- package/build/components/global-styles/index.js +0 -29
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +2 -1
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/typography-utils.js +2 -49
- package/build/components/global-styles/typography-utils.js.map +2 -2
- package/build/components/global-styles/utils.js +0 -396
- package/build/components/global-styles/utils.js.map +3 -3
- package/build/components/inserter/media-tab/media-tab.js +33 -1
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inserter/tips.js +0 -2
- package/build/components/inserter/tips.js.map +2 -2
- package/build/components/media-placeholder/index.js +31 -1
- package/build/components/media-placeholder/index.js.map +3 -3
- package/build/components/media-replace-flow/index.js +29 -1
- package/build/components/media-replace-flow/index.js.map +3 -3
- package/build/components/{global-styles/context.js → media-upload-modal/index.js} +8 -23
- package/build/components/media-upload-modal/index.js.map +7 -0
- package/build/hooks/allowed-blocks.js +3 -8
- package/build/hooks/allowed-blocks.js.map +3 -3
- package/build/hooks/block-style-variation.js +10 -23
- package/build/hooks/block-style-variation.js.map +2 -2
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +2 -2
- package/build/hooks/fit-text.js +2 -2
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +2 -2
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +2 -2
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +3 -3
- package/build-module/components/background-image-control/index.js +1 -1
- package/build-module/components/background-image-control/index.js.map +2 -2
- package/build-module/components/block-quick-navigation/index.js +1 -0
- package/build-module/components/block-quick-navigation/index.js.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.js +2 -5
- package/build-module/components/block-toolbar/switch-section-style.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +2 -1
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +2 -1
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +2 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/filters-panel.js +2 -1
- package/build-module/components/global-styles/filters-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -167
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +1 -29
- package/build-module/components/global-styles/index.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +2 -1
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-utils.js +1 -49
- package/build-module/components/global-styles/typography-utils.js.map +2 -2
- package/build-module/components/global-styles/utils.js +0 -372
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +34 -2
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inserter/tips.js +0 -2
- package/build-module/components/inserter/tips.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +31 -1
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-replace-flow/index.js +29 -1
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/media-upload-modal/index.js +7 -0
- package/build-module/components/media-upload-modal/index.js.map +7 -0
- package/build-module/hooks/allowed-blocks.js +3 -8
- package/build-module/hooks/allowed-blocks.js.map +2 -2
- package/build-module/hooks/block-style-variation.js +8 -25
- package/build-module/hooks/block-style-variation.js.map +2 -2
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +2 -2
- package/build-module/hooks/fit-text.js +2 -2
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +1 -1
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/use-typography-props.js +1 -1
- package/build-module/hooks/use-typography-props.js.map +2 -2
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +2 -2
- package/build-style/style-rtl.css +10 -6
- package/build-style/style.css +10 -6
- package/package.json +36 -35
- package/src/components/background-image-control/index.js +1 -1
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +1 -0
- package/src/components/block-quick-navigation/style.scss +5 -0
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/block-toolbar/switch-section-style.js +2 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/global-styles/border-panel.js +2 -1
- package/src/components/global-styles/color-panel.js +2 -1
- package/src/components/global-styles/color-panel.native.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +2 -1
- package/src/components/global-styles/filters-panel.js +2 -1
- package/src/components/global-styles/hooks.js +1 -200
- package/src/components/global-styles/index.js +1 -17
- package/src/components/global-styles/test/typography-utils.js +0 -806
- package/src/components/global-styles/typography-panel.js +2 -1
- package/src/components/global-styles/typography-utils.js +0 -133
- package/src/components/global-styles/utils.js +0 -568
- package/src/components/inserter/media-tab/media-tab.js +44 -2
- package/src/components/inserter/style.scss +2 -2
- package/src/components/inserter/tips.js +0 -2
- package/src/components/media-placeholder/index.js +41 -1
- package/src/components/media-replace-flow/index.js +39 -1
- package/src/components/media-upload-modal/index.js +18 -0
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/hooks/allowed-blocks.js +3 -11
- package/src/hooks/block-style-variation.js +8 -28
- package/src/hooks/duotone.js +3 -3
- package/src/hooks/fit-text.js +2 -2
- package/src/hooks/font-size.js +1 -1
- package/src/hooks/use-typography-props.js +1 -1
- package/src/private-apis.js +2 -0
- package/src/style.scss +1 -0
- package/tsconfig.json +2 -0
- package/build/components/global-styles/context.js.map +0 -7
- package/build/components/global-styles/get-block-css-selector.js +0 -78
- package/build/components/global-styles/get-block-css-selector.js.map +0 -7
- package/build/components/global-styles/get-global-styles-changes.js +0 -216
- package/build/components/global-styles/get-global-styles-changes.js.map +0 -7
- package/build/components/global-styles/use-global-styles-output.js +0 -998
- package/build/components/global-styles/use-global-styles-output.js.map +0 -7
- package/build-module/components/global-styles/context.js +0 -17
- package/build-module/components/global-styles/context.js.map +0 -7
- package/build-module/components/global-styles/get-block-css-selector.js +0 -54
- package/build-module/components/global-styles/get-block-css-selector.js.map +0 -7
- package/build-module/components/global-styles/get-global-styles-changes.js +0 -182
- package/build-module/components/global-styles/get-global-styles-changes.js.map +0 -7
- package/build-module/components/global-styles/use-global-styles-output.js +0 -979
- package/build-module/components/global-styles/use-global-styles-output.js.map +0 -7
- package/src/components/global-styles/README.md +0 -190
- package/src/components/global-styles/context.js +0 -16
- package/src/components/global-styles/get-block-css-selector.js +0 -114
- package/src/components/global-styles/get-global-styles-changes.js +0 -252
- package/src/components/global-styles/test/get-global-styles-changes.js +0 -290
- package/src/components/global-styles/test/use-global-styles-output.js +0 -1131
- package/src/components/global-styles/test/utils.js +0 -499
- package/src/components/global-styles/use-global-styles-output.js +0 -1487
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
-
import { useContext } from '@wordpress/element';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Internal dependencies
|
|
@@ -18,7 +17,6 @@ import { useContext } from '@wordpress/element';
|
|
|
18
17
|
import useStylesForBlocks from '../block-styles/use-styles-for-block';
|
|
19
18
|
import { replaceActiveStyle } from '../block-styles/utils';
|
|
20
19
|
import { store as blockEditorStore } from '../../store';
|
|
21
|
-
import { GlobalStylesContext } from '../global-styles';
|
|
22
20
|
import { globalStylesDataKey } from '../../store/private-keys';
|
|
23
21
|
import { getVariationStylesWithRefValues } from '../../hooks/block-style-variation';
|
|
24
22
|
|
|
@@ -47,7 +45,6 @@ function SwitchSectionStyle( { clientId } ) {
|
|
|
47
45
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
48
46
|
|
|
49
47
|
// Get global styles data
|
|
50
|
-
const { merged: mergedConfig } = useContext( GlobalStylesContext );
|
|
51
48
|
const { globalSettings, globalStyles, blockName } = useSelect(
|
|
52
49
|
( select ) => {
|
|
53
50
|
const settings = select( blockEditorStore ).getSettings();
|
|
@@ -64,8 +61,8 @@ function SwitchSectionStyle( { clientId } ) {
|
|
|
64
61
|
const activeStyleBackground = activeStyle?.name
|
|
65
62
|
? getVariationStylesWithRefValues(
|
|
66
63
|
{
|
|
67
|
-
settings:
|
|
68
|
-
styles:
|
|
64
|
+
settings: globalSettings,
|
|
65
|
+
styles: globalStyles,
|
|
69
66
|
},
|
|
70
67
|
blockName,
|
|
71
68
|
activeStyle.name
|
|
@@ -11,13 +11,14 @@ import {
|
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
|
+
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
18
19
|
import BorderRadiusControl from '../border-radius-control';
|
|
19
20
|
import { useColorsPerOrigin } from './hooks';
|
|
20
|
-
import {
|
|
21
|
+
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
21
22
|
import { setImmutably } from '../../utils/object';
|
|
22
23
|
import { useBorderPanelLabel } from '../../hooks/border';
|
|
23
24
|
import { ShadowPopover, useShadowPresets } from './shadow-panel-components';
|
|
@@ -21,13 +21,14 @@ import {
|
|
|
21
21
|
} from '@wordpress/components';
|
|
22
22
|
import { useCallback, useRef } from '@wordpress/element';
|
|
23
23
|
import { __ } from '@wordpress/i18n';
|
|
24
|
+
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Internal dependencies
|
|
27
28
|
*/
|
|
28
29
|
import ColorGradientControl from '../colors-gradients/control';
|
|
29
30
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
30
|
-
import {
|
|
31
|
+
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
31
32
|
import { setImmutably } from '../../utils/object';
|
|
32
33
|
import { unlock } from '../../lock-unlock';
|
|
33
34
|
import { reset as resetIcon } from '@wordpress/icons';
|
|
@@ -5,13 +5,13 @@ import { useSelect } from '@wordpress/data';
|
|
|
5
5
|
import { useEffect, useState, useMemo, useCallback } from '@wordpress/element';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
|
+
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
13
|
import PanelColorGradientSettings from '../colors-gradients/panel-color-gradient-settings';
|
|
13
14
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
14
|
-
import { getValueFromVariable } from './utils';
|
|
15
15
|
import { setImmutably } from '../../utils/object';
|
|
16
16
|
import ContrastChecker from '../contrast-checker';
|
|
17
17
|
import InspectorControls from '../inspector-controls';
|
|
@@ -17,11 +17,12 @@ import {
|
|
|
17
17
|
} from '@wordpress/components';
|
|
18
18
|
import { Icon, alignNone, stretchWide } from '@wordpress/icons';
|
|
19
19
|
import { useCallback, useState, Platform } from '@wordpress/element';
|
|
20
|
+
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Internal dependencies
|
|
23
24
|
*/
|
|
24
|
-
import {
|
|
25
|
+
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
25
26
|
import SpacingSizesControl from '../spacing-sizes-control';
|
|
26
27
|
import HeightControl from '../height-control';
|
|
27
28
|
import ChildLayoutControl from '../child-layout-control';
|
|
@@ -24,11 +24,12 @@ import {
|
|
|
24
24
|
import { __, _x } from '@wordpress/i18n';
|
|
25
25
|
import { useCallback, useMemo, useRef } from '@wordpress/element';
|
|
26
26
|
import { reset as resetIcon } from '@wordpress/icons';
|
|
27
|
+
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Internal dependencies
|
|
30
31
|
*/
|
|
31
|
-
import {
|
|
32
|
+
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
32
33
|
import { setImmutably } from '../../utils/object';
|
|
33
34
|
|
|
34
35
|
const EMPTY_ARRAY = [];
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
10
5
|
import { useSelect } from '@wordpress/data';
|
|
11
6
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
12
7
|
import { _x } from '@wordpress/i18n';
|
|
@@ -14,202 +9,8 @@ import { _x } from '@wordpress/i18n';
|
|
|
14
9
|
/**
|
|
15
10
|
* Internal dependencies
|
|
16
11
|
*/
|
|
17
|
-
import { getValueFromVariable, getPresetVariableFromValue } from './utils';
|
|
18
|
-
import { getValueFromObjectPath, setImmutably } from '../../utils/object';
|
|
19
|
-
import { GlobalStylesContext } from './context';
|
|
20
12
|
import { unlock } from '../../lock-unlock';
|
|
21
13
|
|
|
22
|
-
const EMPTY_CONFIG = { settings: {}, styles: {} };
|
|
23
|
-
|
|
24
|
-
const VALID_SETTINGS = [
|
|
25
|
-
'appearanceTools',
|
|
26
|
-
'useRootPaddingAwareAlignments',
|
|
27
|
-
'background.backgroundImage',
|
|
28
|
-
'background.backgroundRepeat',
|
|
29
|
-
'background.backgroundSize',
|
|
30
|
-
'background.backgroundPosition',
|
|
31
|
-
'border.color',
|
|
32
|
-
'border.radius',
|
|
33
|
-
'border.style',
|
|
34
|
-
'border.width',
|
|
35
|
-
'border.radiusSizes',
|
|
36
|
-
'shadow.presets',
|
|
37
|
-
'shadow.defaultPresets',
|
|
38
|
-
'color.background',
|
|
39
|
-
'color.button',
|
|
40
|
-
'color.caption',
|
|
41
|
-
'color.custom',
|
|
42
|
-
'color.customDuotone',
|
|
43
|
-
'color.customGradient',
|
|
44
|
-
'color.defaultDuotone',
|
|
45
|
-
'color.defaultGradients',
|
|
46
|
-
'color.defaultPalette',
|
|
47
|
-
'color.duotone',
|
|
48
|
-
'color.gradients',
|
|
49
|
-
'color.heading',
|
|
50
|
-
'color.link',
|
|
51
|
-
'color.palette',
|
|
52
|
-
'color.text',
|
|
53
|
-
'custom',
|
|
54
|
-
'dimensions.aspectRatio',
|
|
55
|
-
'dimensions.minHeight',
|
|
56
|
-
'layout.contentSize',
|
|
57
|
-
'layout.definitions',
|
|
58
|
-
'layout.wideSize',
|
|
59
|
-
'lightbox.enabled',
|
|
60
|
-
'lightbox.allowEditing',
|
|
61
|
-
'position.fixed',
|
|
62
|
-
'position.sticky',
|
|
63
|
-
'spacing.customSpacingSize',
|
|
64
|
-
'spacing.defaultSpacingSizes',
|
|
65
|
-
'spacing.spacingSizes',
|
|
66
|
-
'spacing.spacingScale',
|
|
67
|
-
'spacing.blockGap',
|
|
68
|
-
'spacing.margin',
|
|
69
|
-
'spacing.padding',
|
|
70
|
-
'spacing.units',
|
|
71
|
-
'typography.fluid',
|
|
72
|
-
'typography.customFontSize',
|
|
73
|
-
'typography.defaultFontSizes',
|
|
74
|
-
'typography.dropCap',
|
|
75
|
-
'typography.fontFamilies',
|
|
76
|
-
'typography.fontSizes',
|
|
77
|
-
'typography.fontStyle',
|
|
78
|
-
'typography.fontWeight',
|
|
79
|
-
'typography.letterSpacing',
|
|
80
|
-
'typography.lineHeight',
|
|
81
|
-
'typography.textAlign',
|
|
82
|
-
'typography.textColumns',
|
|
83
|
-
'typography.textDecoration',
|
|
84
|
-
'typography.textTransform',
|
|
85
|
-
'typography.writingMode',
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
export const useGlobalStylesReset = () => {
|
|
89
|
-
const { user, setUserConfig } = useContext( GlobalStylesContext );
|
|
90
|
-
const config = {
|
|
91
|
-
settings: user.settings,
|
|
92
|
-
styles: user.styles,
|
|
93
|
-
};
|
|
94
|
-
const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
|
|
95
|
-
return [
|
|
96
|
-
canReset,
|
|
97
|
-
useCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),
|
|
98
|
-
];
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
102
|
-
const { setUserConfig, ...configs } = useContext( GlobalStylesContext );
|
|
103
|
-
const appendedBlockPath = blockName ? '.blocks.' + blockName : '';
|
|
104
|
-
const appendedPropertyPath = propertyPath ? '.' + propertyPath : '';
|
|
105
|
-
const contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;
|
|
106
|
-
const globalPath = `settings${ appendedPropertyPath }`;
|
|
107
|
-
const sourceKey = source === 'all' ? 'merged' : source;
|
|
108
|
-
|
|
109
|
-
const settingValue = useMemo( () => {
|
|
110
|
-
const configToUse = configs[ sourceKey ];
|
|
111
|
-
if ( ! configToUse ) {
|
|
112
|
-
throw 'Unsupported source';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if ( propertyPath ) {
|
|
116
|
-
return (
|
|
117
|
-
getValueFromObjectPath( configToUse, contextualPath ) ??
|
|
118
|
-
getValueFromObjectPath( configToUse, globalPath )
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
let result = {};
|
|
123
|
-
VALID_SETTINGS.forEach( ( setting ) => {
|
|
124
|
-
const value =
|
|
125
|
-
getValueFromObjectPath(
|
|
126
|
-
configToUse,
|
|
127
|
-
`settings${ appendedBlockPath }.${ setting }`
|
|
128
|
-
) ??
|
|
129
|
-
getValueFromObjectPath( configToUse, `settings.${ setting }` );
|
|
130
|
-
if ( value !== undefined ) {
|
|
131
|
-
result = setImmutably( result, setting.split( '.' ), value );
|
|
132
|
-
}
|
|
133
|
-
} );
|
|
134
|
-
return result;
|
|
135
|
-
}, [
|
|
136
|
-
configs,
|
|
137
|
-
sourceKey,
|
|
138
|
-
propertyPath,
|
|
139
|
-
contextualPath,
|
|
140
|
-
globalPath,
|
|
141
|
-
appendedBlockPath,
|
|
142
|
-
] );
|
|
143
|
-
|
|
144
|
-
const setSetting = ( newValue ) => {
|
|
145
|
-
setUserConfig( ( currentConfig ) =>
|
|
146
|
-
setImmutably( currentConfig, contextualPath.split( '.' ), newValue )
|
|
147
|
-
);
|
|
148
|
-
};
|
|
149
|
-
return [ settingValue, setSetting ];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function useGlobalStyle(
|
|
153
|
-
path,
|
|
154
|
-
blockName,
|
|
155
|
-
source = 'all',
|
|
156
|
-
{ shouldDecodeEncode = true } = {}
|
|
157
|
-
) {
|
|
158
|
-
const {
|
|
159
|
-
merged: mergedConfig,
|
|
160
|
-
base: baseConfig,
|
|
161
|
-
user: userConfig,
|
|
162
|
-
setUserConfig,
|
|
163
|
-
} = useContext( GlobalStylesContext );
|
|
164
|
-
const appendedPath = path ? '.' + path : '';
|
|
165
|
-
const finalPath = ! blockName
|
|
166
|
-
? `styles${ appendedPath }`
|
|
167
|
-
: `styles.blocks.${ blockName }${ appendedPath }`;
|
|
168
|
-
|
|
169
|
-
const setStyle = ( newValue ) => {
|
|
170
|
-
setUserConfig( ( currentConfig ) =>
|
|
171
|
-
setImmutably(
|
|
172
|
-
currentConfig,
|
|
173
|
-
finalPath.split( '.' ),
|
|
174
|
-
shouldDecodeEncode
|
|
175
|
-
? getPresetVariableFromValue(
|
|
176
|
-
mergedConfig.settings,
|
|
177
|
-
blockName,
|
|
178
|
-
path,
|
|
179
|
-
newValue
|
|
180
|
-
)
|
|
181
|
-
: newValue
|
|
182
|
-
)
|
|
183
|
-
);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
let rawResult, result;
|
|
187
|
-
switch ( source ) {
|
|
188
|
-
case 'all':
|
|
189
|
-
rawResult = getValueFromObjectPath( mergedConfig, finalPath );
|
|
190
|
-
result = shouldDecodeEncode
|
|
191
|
-
? getValueFromVariable( mergedConfig, blockName, rawResult )
|
|
192
|
-
: rawResult;
|
|
193
|
-
break;
|
|
194
|
-
case 'user':
|
|
195
|
-
rawResult = getValueFromObjectPath( userConfig, finalPath );
|
|
196
|
-
result = shouldDecodeEncode
|
|
197
|
-
? getValueFromVariable( mergedConfig, blockName, rawResult )
|
|
198
|
-
: rawResult;
|
|
199
|
-
break;
|
|
200
|
-
case 'base':
|
|
201
|
-
rawResult = getValueFromObjectPath( baseConfig, finalPath );
|
|
202
|
-
result = shouldDecodeEncode
|
|
203
|
-
? getValueFromVariable( baseConfig, blockName, rawResult )
|
|
204
|
-
: rawResult;
|
|
205
|
-
break;
|
|
206
|
-
default:
|
|
207
|
-
throw 'Unsupported source';
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return [ result, setStyle ];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
14
|
/**
|
|
214
15
|
* React hook that overrides a global settings object with block and element specific settings.
|
|
215
16
|
*
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
useGlobalStylesReset,
|
|
3
|
-
useGlobalSetting,
|
|
4
|
-
useGlobalStyle,
|
|
5
|
-
useSettingsForBlockElement,
|
|
6
|
-
} from './hooks';
|
|
7
|
-
export { getBlockCSSSelector } from './get-block-css-selector';
|
|
8
|
-
export {
|
|
9
|
-
getLayoutStyles,
|
|
10
|
-
getBlockSelectors,
|
|
11
|
-
toStyles,
|
|
12
|
-
useGlobalStylesOutput,
|
|
13
|
-
useGlobalStylesOutputWithConfig,
|
|
14
|
-
} from './use-global-styles-output';
|
|
15
|
-
export { GlobalStylesContext } from './context';
|
|
1
|
+
export { useSettingsForBlockElement } from './hooks';
|
|
16
2
|
export {
|
|
17
3
|
default as TypographyPanel,
|
|
18
4
|
useHasTypographyPanel,
|
|
@@ -37,5 +23,3 @@ export {
|
|
|
37
23
|
default as BackgroundPanel,
|
|
38
24
|
useHasBackgroundPanel,
|
|
39
25
|
} from './background-panel';
|
|
40
|
-
export { areGlobalStyleConfigsEqual } from './utils';
|
|
41
|
-
export { default as getGlobalStylesChanges } from './get-global-styles-changes';
|