@wordpress/edit-site 4.9.0 → 4.12.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 +6 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js +84 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build/components/add-new-template/add-custom-template-modal.js +82 -61
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +94 -81
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +574 -57
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/code-editor/index.js +17 -4
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/editor/index.js +16 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +6 -0
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +191 -21
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +13 -17
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +59 -7
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +157 -0
- package/build/components/global-styles/screen-heading-color.js.map +1 -0
- package/build/components/global-styles/screen-link-color.js +48 -14
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +73 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +217 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/ui.js +11 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +298 -61
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +49 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +22 -10
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +2 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/list/actions/index.js +1 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/save-button/index.js +2 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar/template-card/template-actions.js +1 -1
- package/build/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +11 -3
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +2 -21
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +86 -0
- package/build/hooks/template-part-edit.js.map +1 -0
- package/build/store/selectors.js +4 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +77 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js +82 -61
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +96 -84
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +555 -50
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/code-editor/index.js +18 -5
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +5 -0
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +191 -22
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +4 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +14 -19
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +59 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +143 -0
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
- package/build-module/components/global-styles/screen-link-color.js +47 -14
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +74 -13
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +204 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/ui.js +10 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +294 -69
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +47 -4
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +25 -12
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +3 -2
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +1 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +3 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +12 -3
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -22
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +67 -0
- package/build-module/hooks/template-part-edit.js.map +1 -0
- package/build-module/store/selectors.js +5 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +55 -48
- package/build-style/style.css +55 -48
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-generic-template-modal.js +97 -0
- package/src/components/add-new-template/add-custom-template-modal.js +93 -68
- package/src/components/add-new-template/new-template.js +126 -95
- package/src/components/add-new-template/style.scss +41 -8
- package/src/components/add-new-template/utils.js +622 -80
- package/src/components/block-editor/index.js +0 -2
- package/src/components/code-editor/index.js +15 -5
- package/src/components/editor/index.js +11 -0
- package/src/components/error-boundary/index.js +5 -0
- package/src/components/global-styles/dimensions-panel.js +214 -24
- package/src/components/global-styles/global-styles-provider.js +8 -9
- package/src/components/global-styles/hooks.js +18 -0
- package/src/components/global-styles/screen-color-palette.js +25 -27
- package/src/components/global-styles/screen-colors.js +55 -7
- package/src/components/global-styles/screen-heading-color.js +201 -0
- package/src/components/global-styles/screen-link-color.js +65 -23
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/style.scss +14 -11
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +296 -2
- package/src/components/global-styles/typography-panel.js +85 -16
- package/src/components/global-styles/typography-utils.js +228 -0
- package/src/components/global-styles/ui.js +13 -0
- package/src/components/global-styles/use-global-styles-output.js +387 -89
- package/src/components/global-styles/utils.js +43 -2
- package/src/components/header/index.js +37 -13
- package/src/components/header/style.scss +5 -3
- package/src/components/header/undo-redo/redo.js +6 -2
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/list/actions/index.js +3 -1
- package/src/components/list/style.scss +0 -8
- package/src/components/save-button/index.js +10 -13
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/src/components/sidebar/style.scss +4 -0
- package/src/components/sidebar/template-card/template-actions.js +3 -1
- package/src/components/template-details/edit-template-title.js +10 -2
- package/src/components/template-details/index.js +7 -22
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
- package/src/components/test/error-boundary.js +38 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/store/selectors.js +11 -5
- package/src/style.scss +0 -1
- package/build/components/edit-template-part-menu-button/index.js +0 -90
- package/build/components/edit-template-part-menu-button/index.js.map +0 -1
- package/build-module/components/edit-template-part-menu-button/index.js +0 -72
- package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
- package/src/components/edit-template-part-menu-button/index.js +0 -82
|
@@ -3,29 +3,38 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { first, forEach, get, isEmpty,
|
|
6
|
+
import { first, forEach, get, isEmpty, kebabCase, pickBy, reduce, set } from 'lodash';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, __EXPERIMENTAL_ELEMENTS as ELEMENTS, getBlockTypes } from '@wordpress/blocks';
|
|
12
|
-
import {
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
13
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
13
14
|
import { getCSSRules } from '@wordpress/style-engine';
|
|
14
|
-
import { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '@wordpress/block-editor';
|
|
15
|
+
import { __unstablePresetDuotoneFilter as PresetDuotoneFilter, __experimentalGetGapCSSValue as getGapCSSValue, store as blockEditorStore } from '@wordpress/block-editor';
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
|
-
import { PRESET_METADATA, ROOT_BLOCK_SELECTOR } from './utils';
|
|
20
|
+
import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
|
|
20
21
|
import { GlobalStylesContext } from './context';
|
|
21
|
-
import { useSetting } from './hooks';
|
|
22
|
+
import { useSetting } from './hooks'; // List of block support features that can have their related styles
|
|
23
|
+
// generated under their own feature level selector rather than the block's.
|
|
24
|
+
|
|
25
|
+
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
26
|
+
__experimentalBorder: 'border',
|
|
27
|
+
color: 'color',
|
|
28
|
+
spacing: 'spacing',
|
|
29
|
+
typography: 'typography'
|
|
30
|
+
};
|
|
22
31
|
|
|
23
32
|
function compileStyleValue(uncompiledValue) {
|
|
24
33
|
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
25
34
|
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
26
35
|
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
27
36
|
|
|
28
|
-
if (startsWith(
|
|
37
|
+
if (uncompiledValue !== null && uncompiledValue !== void 0 && uncompiledValue.startsWith(VARIABLE_REFERENCE_PREFIX)) {
|
|
29
38
|
const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
|
|
30
39
|
return `var(--wp--${variable})`;
|
|
31
40
|
}
|
|
@@ -36,13 +45,15 @@ function compileStyleValue(uncompiledValue) {
|
|
|
36
45
|
* Transform given preset tree into a set of style declarations.
|
|
37
46
|
*
|
|
38
47
|
* @param {Object} blockPresets
|
|
48
|
+
* @param {Object} mergedSettings Merged theme.json settings.
|
|
39
49
|
*
|
|
40
|
-
* @return {Array} An array of style declarations.
|
|
50
|
+
* @return {Array<Object>} An array of style declarations.
|
|
41
51
|
*/
|
|
42
52
|
|
|
43
53
|
|
|
44
54
|
function getPresetsDeclarations() {
|
|
45
55
|
let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
56
|
+
let mergedSettings = arguments.length > 1 ? arguments[1] : undefined;
|
|
46
57
|
return reduce(PRESET_METADATA, (declarations, _ref) => {
|
|
47
58
|
let {
|
|
48
59
|
path,
|
|
@@ -54,10 +65,10 @@ function getPresetsDeclarations() {
|
|
|
54
65
|
['default', 'theme', 'custom'].forEach(origin => {
|
|
55
66
|
if (presetByOrigin[origin]) {
|
|
56
67
|
presetByOrigin[origin].forEach(value => {
|
|
57
|
-
if (valueKey) {
|
|
68
|
+
if (valueKey && !valueFunc) {
|
|
58
69
|
declarations.push(`--wp--preset--${cssVarInfix}--${kebabCase(value.slug)}: ${value[valueKey]}`);
|
|
59
70
|
} else if (valueFunc && typeof valueFunc === 'function') {
|
|
60
|
-
declarations.push(`--wp--preset--${cssVarInfix}--${kebabCase(value.slug)}: ${valueFunc(value)}`);
|
|
71
|
+
declarations.push(`--wp--preset--${cssVarInfix}--${kebabCase(value.slug)}: ${valueFunc(value, mergedSettings)}`);
|
|
61
72
|
}
|
|
62
73
|
});
|
|
63
74
|
}
|
|
@@ -145,29 +156,47 @@ function flattenTree() {
|
|
|
145
156
|
/**
|
|
146
157
|
* Transform given style tree into a set of style declarations.
|
|
147
158
|
*
|
|
148
|
-
* @param {Object}
|
|
159
|
+
* @param {Object} blockStyles Block styles.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} selector The selector these declarations should attach to.
|
|
162
|
+
*
|
|
163
|
+
* @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
|
|
149
164
|
*
|
|
150
165
|
* @return {Array} An array of style declarations.
|
|
151
166
|
*/
|
|
152
167
|
|
|
153
168
|
|
|
154
|
-
function getStylesDeclarations() {
|
|
169
|
+
export function getStylesDeclarations() {
|
|
155
170
|
let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
171
|
+
let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
172
|
+
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
173
|
+
const isRoot = ROOT_BLOCK_SELECTOR === selector;
|
|
156
174
|
const output = reduce(STYLE_PROPERTY, (declarations, _ref5, key) => {
|
|
157
175
|
let {
|
|
158
176
|
value,
|
|
159
177
|
properties,
|
|
160
|
-
useEngine
|
|
178
|
+
useEngine,
|
|
179
|
+
rootOnly
|
|
161
180
|
} = _ref5;
|
|
181
|
+
|
|
182
|
+
if (rootOnly && !isRoot) {
|
|
183
|
+
return declarations;
|
|
184
|
+
}
|
|
185
|
+
|
|
162
186
|
const pathToValue = value;
|
|
163
187
|
|
|
164
188
|
if (first(pathToValue) === 'elements' || useEngine) {
|
|
165
189
|
return declarations;
|
|
166
190
|
}
|
|
167
191
|
|
|
168
|
-
const styleValue = get(blockStyles, pathToValue);
|
|
192
|
+
const styleValue = get(blockStyles, pathToValue); // Root-level padding styles don't currently support strings with CSS shorthand values.
|
|
193
|
+
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
|
|
194
|
+
|
|
195
|
+
if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
|
|
196
|
+
return declarations;
|
|
197
|
+
}
|
|
169
198
|
|
|
170
|
-
if (!!properties &&
|
|
199
|
+
if (!!properties && typeof styleValue !== 'string') {
|
|
171
200
|
Object.entries(properties).forEach(entry => {
|
|
172
201
|
const [name, prop] = entry;
|
|
173
202
|
|
|
@@ -177,7 +206,7 @@ function getStylesDeclarations() {
|
|
|
177
206
|
return;
|
|
178
207
|
}
|
|
179
208
|
|
|
180
|
-
const cssProperty = kebabCase(name);
|
|
209
|
+
const cssProperty = name.startsWith('--') ? name : kebabCase(name);
|
|
181
210
|
declarations.push(`${cssProperty}: ${compileStyleValue(get(styleValue, [prop]))}`);
|
|
182
211
|
});
|
|
183
212
|
} else if (get(blockStyles, pathToValue, false)) {
|
|
@@ -191,14 +220,136 @@ function getStylesDeclarations() {
|
|
|
191
220
|
|
|
192
221
|
const extraRules = getCSSRules(blockStyles);
|
|
193
222
|
extraRules.forEach(rule => {
|
|
223
|
+
// Don't output padding properties if padding variables are set.
|
|
224
|
+
if (isRoot && useRootPaddingAlign && rule.key.startsWith('padding')) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
194
228
|
const cssProperty = rule.key.startsWith('--') ? rule.key : kebabCase(rule.key);
|
|
195
229
|
output.push(`${cssProperty}: ${compileStyleValue(rule.value)}`);
|
|
196
230
|
});
|
|
197
231
|
return output;
|
|
198
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Get generated CSS for layout styles by looking up layout definitions provided
|
|
235
|
+
* in theme.json, and outputting common layout styles, and specific blockGap values.
|
|
236
|
+
*
|
|
237
|
+
* @param {Object} props
|
|
238
|
+
* @param {Object} props.tree A theme.json tree containing layout definitions.
|
|
239
|
+
* @param {Object} props.style A style object containing spacing values.
|
|
240
|
+
* @param {string} props.selector Selector used to group together layout styling rules.
|
|
241
|
+
* @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.
|
|
242
|
+
* @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.
|
|
243
|
+
* @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.
|
|
244
|
+
* @return {string} Generated CSS rules for the layout styles.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
export function getLayoutStyles(_ref6) {
|
|
248
|
+
var _style$spacing, _tree$settings, _tree$settings$layout, _tree$settings2, _tree$settings2$layou;
|
|
249
|
+
|
|
250
|
+
let {
|
|
251
|
+
tree,
|
|
252
|
+
style,
|
|
253
|
+
selector,
|
|
254
|
+
hasBlockGapSupport,
|
|
255
|
+
hasFallbackGapSupport,
|
|
256
|
+
fallbackGapValue
|
|
257
|
+
} = _ref6;
|
|
258
|
+
let ruleset = '';
|
|
259
|
+
let gapValue = hasBlockGapSupport ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap) : ''; // Ensure a fallback gap value for the root layout definitions,
|
|
260
|
+
// and use a fallback value if one is provided for the current block.
|
|
261
|
+
|
|
262
|
+
if (hasFallbackGapSupport) {
|
|
263
|
+
if (selector === ROOT_BLOCK_SELECTOR) {
|
|
264
|
+
gapValue = !gapValue ? '0.5em' : gapValue;
|
|
265
|
+
} else if (!hasBlockGapSupport && fallbackGapValue) {
|
|
266
|
+
gapValue = fallbackGapValue;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (gapValue && tree !== null && tree !== void 0 && (_tree$settings = tree.settings) !== null && _tree$settings !== void 0 && (_tree$settings$layout = _tree$settings.layout) !== null && _tree$settings$layout !== void 0 && _tree$settings$layout.definitions) {
|
|
271
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref7 => {
|
|
272
|
+
let {
|
|
273
|
+
className,
|
|
274
|
+
name,
|
|
275
|
+
spacingStyles
|
|
276
|
+
} = _ref7;
|
|
277
|
+
|
|
278
|
+
// Allow skipping default layout for themes that opt-in to block styles, but opt-out of blockGap.
|
|
279
|
+
if (!hasBlockGapSupport && 'default' === name) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (spacingStyles !== null && spacingStyles !== void 0 && spacingStyles.length) {
|
|
284
|
+
spacingStyles.forEach(spacingStyle => {
|
|
285
|
+
const declarations = [];
|
|
286
|
+
|
|
287
|
+
if (spacingStyle.rules) {
|
|
288
|
+
Object.entries(spacingStyle.rules).forEach(_ref8 => {
|
|
289
|
+
let [cssProperty, cssValue] = _ref8;
|
|
290
|
+
declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (declarations.length) {
|
|
295
|
+
let combinedSelector = '';
|
|
296
|
+
|
|
297
|
+
if (!hasBlockGapSupport) {
|
|
298
|
+
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
299
|
+
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})` : `:where(${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})`;
|
|
300
|
+
} else {
|
|
301
|
+
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}); // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
|
|
309
|
+
|
|
310
|
+
if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
|
|
311
|
+
ruleset += `${selector} { --wp--style--block-gap: ${gapValue}; }`;
|
|
312
|
+
}
|
|
313
|
+
} // Output base styles
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
if (selector === ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
|
|
317
|
+
const validDisplayModes = ['block', 'flex', 'grid'];
|
|
318
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
|
|
319
|
+
let {
|
|
320
|
+
className,
|
|
321
|
+
displayMode,
|
|
322
|
+
baseStyles
|
|
323
|
+
} = _ref9;
|
|
324
|
+
|
|
325
|
+
if (displayMode && validDisplayModes.includes(displayMode)) {
|
|
326
|
+
ruleset += `${selector} .${className} { display:${displayMode}; }`;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (baseStyles !== null && baseStyles !== void 0 && baseStyles.length) {
|
|
330
|
+
baseStyles.forEach(baseStyle => {
|
|
331
|
+
const declarations = [];
|
|
199
332
|
|
|
333
|
+
if (baseStyle.rules) {
|
|
334
|
+
Object.entries(baseStyle.rules).forEach(_ref10 => {
|
|
335
|
+
let [cssProperty, cssValue] = _ref10;
|
|
336
|
+
declarations.push(`${cssProperty}: ${cssValue}`);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (declarations.length) {
|
|
341
|
+
const combinedSelector = `${selector} .${className}${(baseStyle === null || baseStyle === void 0 ? void 0 : baseStyle.selector) || ''}`;
|
|
342
|
+
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return ruleset;
|
|
350
|
+
}
|
|
200
351
|
export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
201
|
-
var _tree$
|
|
352
|
+
var _tree$styles3;
|
|
202
353
|
|
|
203
354
|
const nodes = [];
|
|
204
355
|
|
|
@@ -218,25 +369,32 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
218
369
|
});
|
|
219
370
|
}
|
|
220
371
|
|
|
221
|
-
forEach(
|
|
222
|
-
|
|
372
|
+
forEach(ELEMENTS, (selector, name) => {
|
|
373
|
+
var _tree$styles;
|
|
374
|
+
|
|
375
|
+
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
376
|
+
var _tree$styles2;
|
|
377
|
+
|
|
223
378
|
nodes.push({
|
|
224
|
-
styles:
|
|
225
|
-
selector
|
|
379
|
+
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
|
|
380
|
+
selector
|
|
226
381
|
});
|
|
227
382
|
}
|
|
228
383
|
}); // Iterate over blocks: they can have styles & elements.
|
|
229
384
|
|
|
230
|
-
forEach((_tree$
|
|
385
|
+
forEach((_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks, (node, blockName) => {
|
|
231
386
|
var _blockSelectors$block;
|
|
232
387
|
|
|
233
388
|
const blockStyles = pickStyleKeys(node);
|
|
234
389
|
|
|
235
390
|
if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
|
|
236
391
|
nodes.push({
|
|
237
|
-
|
|
392
|
+
duotoneSelector: blockSelectors[blockName].duotoneSelector,
|
|
393
|
+
fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
|
|
394
|
+
hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
|
|
238
395
|
selector: blockSelectors[blockName].selector,
|
|
239
|
-
|
|
396
|
+
styles: blockStyles,
|
|
397
|
+
featureSelectors: blockSelectors[blockName].featureSelectors
|
|
240
398
|
});
|
|
241
399
|
}
|
|
242
400
|
|
|
@@ -255,7 +413,7 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
255
413
|
return nodes;
|
|
256
414
|
};
|
|
257
415
|
export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
258
|
-
var _tree$
|
|
416
|
+
var _tree$settings3, _tree$settings4;
|
|
259
417
|
|
|
260
418
|
const nodes = [];
|
|
261
419
|
|
|
@@ -265,10 +423,10 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
265
423
|
|
|
266
424
|
const pickPresets = treeToPickFrom => {
|
|
267
425
|
const presets = {};
|
|
268
|
-
PRESET_METADATA.forEach(
|
|
426
|
+
PRESET_METADATA.forEach(_ref11 => {
|
|
269
427
|
let {
|
|
270
428
|
path
|
|
271
|
-
} =
|
|
429
|
+
} = _ref11;
|
|
272
430
|
const value = get(treeToPickFrom, path, false);
|
|
273
431
|
|
|
274
432
|
if (value !== false) {
|
|
@@ -280,7 +438,7 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
280
438
|
|
|
281
439
|
|
|
282
440
|
const presets = pickPresets(tree.settings);
|
|
283
|
-
const custom = (_tree$
|
|
441
|
+
const custom = (_tree$settings3 = tree.settings) === null || _tree$settings3 === void 0 ? void 0 : _tree$settings3.custom;
|
|
284
442
|
|
|
285
443
|
if (!isEmpty(presets) || !!custom) {
|
|
286
444
|
nodes.push({
|
|
@@ -291,7 +449,7 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
291
449
|
} // Blocks.
|
|
292
450
|
|
|
293
451
|
|
|
294
|
-
forEach((_tree$
|
|
452
|
+
forEach((_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.blocks, (node, blockName) => {
|
|
295
453
|
const blockPresets = pickPresets(node);
|
|
296
454
|
const blockCustom = node.custom;
|
|
297
455
|
|
|
@@ -308,13 +466,13 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
308
466
|
export const toCustomProperties = (tree, blockSelectors) => {
|
|
309
467
|
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
310
468
|
let ruleset = '';
|
|
311
|
-
settings.forEach(
|
|
469
|
+
settings.forEach(_ref12 => {
|
|
312
470
|
let {
|
|
313
471
|
presets,
|
|
314
472
|
custom,
|
|
315
473
|
selector
|
|
316
|
-
} =
|
|
317
|
-
const declarations = getPresetsDeclarations(presets);
|
|
474
|
+
} = _ref12;
|
|
475
|
+
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
318
476
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
319
477
|
|
|
320
478
|
if (customProps.length > 0) {
|
|
@@ -327,9 +485,13 @@ export const toCustomProperties = (tree, blockSelectors) => {
|
|
|
327
485
|
});
|
|
328
486
|
return ruleset;
|
|
329
487
|
};
|
|
330
|
-
export const toStyles = (tree, blockSelectors, hasBlockGapSupport)
|
|
488
|
+
export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
|
|
489
|
+
var _tree$settings5;
|
|
490
|
+
|
|
491
|
+
let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
331
492
|
const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
|
|
332
493
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
494
|
+
const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.useRootPaddingAwareAlignments;
|
|
333
495
|
/*
|
|
334
496
|
* Reset default browser margin on the root body element.
|
|
335
497
|
* This is set on the root selector **before** generating the ruleset
|
|
@@ -340,12 +502,41 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
|
|
|
340
502
|
*/
|
|
341
503
|
|
|
342
504
|
let ruleset = 'body {margin: 0;}';
|
|
343
|
-
|
|
505
|
+
|
|
506
|
+
if (useRootPaddingAlign) {
|
|
507
|
+
ruleset = 'body { margin: 0; padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } .has-global-padding > .alignfull > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }';
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
nodesWithStyles.forEach(_ref13 => {
|
|
344
511
|
let {
|
|
345
512
|
selector,
|
|
346
513
|
duotoneSelector,
|
|
347
|
-
styles
|
|
348
|
-
|
|
514
|
+
styles,
|
|
515
|
+
fallbackGapValue,
|
|
516
|
+
hasLayoutSupport,
|
|
517
|
+
featureSelectors
|
|
518
|
+
} = _ref13;
|
|
519
|
+
|
|
520
|
+
// Process styles for block support features with custom feature level
|
|
521
|
+
// CSS selectors set.
|
|
522
|
+
if (featureSelectors) {
|
|
523
|
+
Object.entries(featureSelectors).forEach(_ref14 => {
|
|
524
|
+
let [featureName, featureSelector] = _ref14;
|
|
525
|
+
|
|
526
|
+
if (styles !== null && styles !== void 0 && styles[featureName]) {
|
|
527
|
+
const featureStyles = {
|
|
528
|
+
[featureName]: styles[featureName]
|
|
529
|
+
};
|
|
530
|
+
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
531
|
+
delete styles[featureName];
|
|
532
|
+
|
|
533
|
+
if (!!featureDeclarations.length) {
|
|
534
|
+
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
349
540
|
const duotoneStyles = {};
|
|
350
541
|
|
|
351
542
|
if (styles !== null && styles !== void 0 && styles.filter) {
|
|
@@ -362,31 +553,43 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
|
|
|
362
553
|
}
|
|
363
554
|
|
|
364
555
|
ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
|
|
365
|
-
} // Process
|
|
556
|
+
} // Process blockGap and layout styles.
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
|
|
560
|
+
ruleset += getLayoutStyles({
|
|
561
|
+
tree,
|
|
562
|
+
style: styles,
|
|
563
|
+
selector,
|
|
564
|
+
hasBlockGapSupport,
|
|
565
|
+
hasFallbackGapSupport,
|
|
566
|
+
fallbackGapValue
|
|
567
|
+
});
|
|
568
|
+
} // Process the remaining block styles (they use either normal block class or __experimentalSelector).
|
|
366
569
|
|
|
367
570
|
|
|
368
|
-
const declarations = getStylesDeclarations(styles);
|
|
571
|
+
const declarations = getStylesDeclarations(styles, selector, useRootPaddingAlign);
|
|
369
572
|
|
|
370
573
|
if (declarations !== null && declarations !== void 0 && declarations.length) {
|
|
371
574
|
ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
|
|
372
575
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
373
576
|
|
|
374
577
|
|
|
375
|
-
const
|
|
376
|
-
let [key] =
|
|
578
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref15 => {
|
|
579
|
+
let [key] = _ref15;
|
|
377
580
|
return key.startsWith(':');
|
|
378
581
|
});
|
|
379
582
|
|
|
380
|
-
if (
|
|
381
|
-
|
|
382
|
-
let [pseudoKey,
|
|
383
|
-
const pseudoDeclarations = getStylesDeclarations(
|
|
583
|
+
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
584
|
+
pseudoSelectorStyles.forEach(_ref16 => {
|
|
585
|
+
let [pseudoKey, pseudoStyle] = _ref16;
|
|
586
|
+
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
384
587
|
|
|
385
588
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
386
589
|
return;
|
|
387
590
|
} // `selector` maybe provided in a form
|
|
388
591
|
// where block level selectors have sub element
|
|
389
|
-
// selectors appended to them as a comma
|
|
592
|
+
// selectors appended to them as a comma separated
|
|
390
593
|
// string.
|
|
391
594
|
// e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;
|
|
392
595
|
// Split and append pseudo selector to create
|
|
@@ -395,8 +598,8 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
|
|
|
395
598
|
|
|
396
599
|
const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
|
|
397
600
|
|
|
398
|
-
const
|
|
399
|
-
ruleset = ruleset +
|
|
601
|
+
const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
|
|
602
|
+
ruleset = ruleset + pseudoRule;
|
|
400
603
|
});
|
|
401
604
|
}
|
|
402
605
|
});
|
|
@@ -407,15 +610,19 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
|
|
|
407
610
|
ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
|
|
408
611
|
|
|
409
612
|
if (hasBlockGapSupport) {
|
|
613
|
+
var _tree$styles4, _tree$styles4$spacing;
|
|
614
|
+
|
|
615
|
+
// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
|
|
616
|
+
const gapValue = getGapCSSValue(tree === null || tree === void 0 ? void 0 : (_tree$styles4 = tree.styles) === null || _tree$styles4 === void 0 ? void 0 : (_tree$styles4$spacing = _tree$styles4.spacing) === null || _tree$styles4$spacing === void 0 ? void 0 : _tree$styles4$spacing.blockGap) || '0.5em';
|
|
410
617
|
ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
|
|
411
|
-
ruleset = ruleset +
|
|
618
|
+
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
412
619
|
}
|
|
413
620
|
|
|
414
|
-
nodesWithSettings.forEach(
|
|
621
|
+
nodesWithSettings.forEach(_ref17 => {
|
|
415
622
|
let {
|
|
416
623
|
selector,
|
|
417
624
|
presets
|
|
418
|
-
} =
|
|
625
|
+
} = _ref17;
|
|
419
626
|
|
|
420
627
|
if (ROOT_BLOCK_SELECTOR === selector) {
|
|
421
628
|
// Do not add extra specificity for top-level classes.
|
|
@@ -432,59 +639,77 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
|
|
|
432
639
|
};
|
|
433
640
|
export function toSvgFilters(tree, blockSelectors) {
|
|
434
641
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
435
|
-
return nodesWithSettings.flatMap(
|
|
642
|
+
return nodesWithSettings.flatMap(_ref18 => {
|
|
436
643
|
let {
|
|
437
644
|
presets
|
|
438
|
-
} =
|
|
645
|
+
} = _ref18;
|
|
439
646
|
return getPresetsSvgFilters(presets);
|
|
440
647
|
});
|
|
441
648
|
}
|
|
442
|
-
|
|
443
|
-
const getBlockSelectors = blockTypes => {
|
|
649
|
+
export const getBlockSelectors = blockTypes => {
|
|
444
650
|
const result = {};
|
|
445
651
|
blockTypes.forEach(blockType => {
|
|
446
|
-
var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2
|
|
652
|
+
var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports4, _blockType$supports4$, _blockType$supports4$2;
|
|
447
653
|
|
|
448
654
|
const name = blockType.name;
|
|
449
655
|
const selector = (_blockType$supports$_ = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports = blockType.supports) === null || _blockType$supports === void 0 ? void 0 : _blockType$supports.__experimentalSelector) !== null && _blockType$supports$_ !== void 0 ? _blockType$supports$_ : '.wp-block-' + name.replace('core/', '').replace('/', '-');
|
|
450
656
|
const duotoneSelector = (_blockType$supports$c = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.color) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalDuotone) !== null && _blockType$supports$c !== void 0 ? _blockType$supports$c : null;
|
|
657
|
+
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
|
|
658
|
+
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports4 = blockType.supports) === null || _blockType$supports4 === void 0 ? void 0 : (_blockType$supports4$ = _blockType$supports4.spacing) === null || _blockType$supports4$ === void 0 ? void 0 : (_blockType$supports4$2 = _blockType$supports4$.blockGap) === null || _blockType$supports4$2 === void 0 ? void 0 : _blockType$supports4$2.__experimentalDefault; // For each block support feature add any custom selectors.
|
|
659
|
+
|
|
660
|
+
const featureSelectors = {};
|
|
661
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref19 => {
|
|
662
|
+
var _blockType$supports5, _blockType$supports5$;
|
|
663
|
+
|
|
664
|
+
let [featureKey, featureName] = _ref19;
|
|
665
|
+
const featureSelector = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports5 = blockType.supports) === null || _blockType$supports5 === void 0 ? void 0 : (_blockType$supports5$ = _blockType$supports5[featureKey]) === null || _blockType$supports5$ === void 0 ? void 0 : _blockType$supports5$.__experimentalSelector;
|
|
666
|
+
|
|
667
|
+
if (featureSelector) {
|
|
668
|
+
featureSelectors[featureName] = scopeSelector(selector, featureSelector);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
451
671
|
result[name] = {
|
|
672
|
+
duotoneSelector,
|
|
673
|
+
fallbackGapValue,
|
|
674
|
+
featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : undefined,
|
|
675
|
+
hasLayoutSupport,
|
|
452
676
|
name,
|
|
453
|
-
selector
|
|
454
|
-
duotoneSelector
|
|
677
|
+
selector
|
|
455
678
|
};
|
|
456
679
|
});
|
|
457
680
|
return result;
|
|
458
681
|
};
|
|
459
|
-
|
|
460
682
|
export function useGlobalStylesOutput() {
|
|
461
|
-
const [stylesheets, setStylesheets] = useState([]);
|
|
462
|
-
const [settings, setSettings] = useState({});
|
|
463
|
-
const [svgFilters, setSvgFilters] = useState({});
|
|
464
683
|
const {
|
|
465
684
|
merged: mergedConfig
|
|
466
685
|
} = useContext(GlobalStylesContext);
|
|
467
686
|
const [blockGap] = useSetting('spacing.blockGap');
|
|
468
687
|
const hasBlockGapSupport = blockGap !== null;
|
|
469
|
-
|
|
688
|
+
const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
|
|
689
|
+
|
|
690
|
+
const disableLayoutStyles = useSelect(select => {
|
|
691
|
+
const {
|
|
692
|
+
getSettings
|
|
693
|
+
} = select(blockEditorStore);
|
|
694
|
+
return !!getSettings().disableLayoutStyles;
|
|
695
|
+
});
|
|
696
|
+
return useMemo(() => {
|
|
470
697
|
if (!(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.styles) || !(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.settings)) {
|
|
471
|
-
return;
|
|
698
|
+
return [];
|
|
472
699
|
}
|
|
473
700
|
|
|
474
701
|
const blockSelectors = getBlockSelectors(getBlockTypes());
|
|
475
702
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
476
|
-
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport);
|
|
703
|
+
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
477
704
|
const filters = toSvgFilters(mergedConfig, blockSelectors);
|
|
478
|
-
|
|
705
|
+
const stylesheets = [{
|
|
479
706
|
css: customProperties,
|
|
480
707
|
isGlobalStyles: true
|
|
481
708
|
}, {
|
|
482
709
|
css: globalStyles,
|
|
483
710
|
isGlobalStyles: true
|
|
484
|
-
}]
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}, [mergedConfig]);
|
|
488
|
-
return [stylesheets, settings, svgFilters, hasBlockGapSupport];
|
|
711
|
+
}];
|
|
712
|
+
return [stylesheets, mergedConfig.settings, filters];
|
|
713
|
+
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
489
714
|
}
|
|
490
715
|
//# sourceMappingURL=use-global-styles-output.js.map
|