@wordpress/edit-site 4.10.0 → 4.12.1-next.d6164808d3.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 +4 -0
- package/build/components/add-new-template/add-custom-template-modal.js +26 -44
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +45 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +493 -242
- 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/block-editor/resizable-editor.js +26 -12
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +3 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +280 -20
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +4 -4
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +1 -1
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +51 -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-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 +82 -14
- 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 +183 -52
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +85 -5
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/document-actions/index.js +1 -0
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +27 -12
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +0 -4
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +13 -3
- package/build/components/header/more-menu/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/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/default-sidebar.js +11 -1
- package/build/components/sidebar/default-sidebar.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/plugin-sidebar/index.js +11 -1
- package/build/components/sidebar/plugin-sidebar/index.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 +1 -1
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +19 -9
- 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-details/template-part-area-selector.js +47 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -0
- 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/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +27 -45
- 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 +45 -25
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +489 -230
- 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/block-editor/resizable-editor.js +26 -12
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +278 -22
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +4 -4
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +1 -1
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +51 -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-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 +83 -15
- 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 +182 -61
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +82 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +1 -0
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +30 -14
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +0 -4
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +13 -3
- package/build-module/components/header/more-menu/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/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/default-sidebar.js +9 -1
- package/build-module/components/sidebar/default-sidebar.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/plugin-sidebar/index.js +9 -1
- package/build-module/components/sidebar/plugin-sidebar/index.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 +1 -1
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +19 -10
- 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-details/template-part-area-selector.js +35 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
- 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/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +40 -33
- package/build-style/style.css +40 -33
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-template-modal.js +39 -48
- package/src/components/add-new-template/new-template.js +50 -58
- package/src/components/add-new-template/style.scss +20 -8
- package/src/components/add-new-template/utils.js +529 -231
- package/src/components/block-editor/index.js +0 -2
- package/src/components/block-editor/resizable-editor.js +28 -18
- package/src/components/editor/style.scss +1 -0
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +344 -45
- package/src/components/global-styles/hooks.js +6 -3
- package/src/components/global-styles/screen-color-palette.js +1 -1
- package/src/components/global-styles/screen-colors.js +46 -4
- package/src/components/global-styles/screen-heading-color.js +201 -0
- 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 -6
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +143 -4
- package/src/components/global-styles/test/utils.js +68 -8
- package/src/components/global-styles/typography-panel.js +119 -48
- 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 +203 -53
- package/src/components/global-styles/utils.js +70 -4
- package/src/components/header/document-actions/index.js +3 -0
- package/src/components/header/index.js +41 -14
- package/src/components/header/mode-switcher/index.js +0 -3
- package/src/components/header/more-menu/index.js +7 -2
- package/src/components/header/style.scss +5 -3
- package/src/components/header/undo-redo/redo.js +6 -2
- package/src/components/list/actions/index.js +3 -1
- package/src/components/save-button/index.js +10 -13
- package/src/components/sidebar/default-sidebar.js +12 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/src/components/sidebar/plugin-sidebar/index.js +12 -0
- 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 +7 -3
- package/src/components/template-details/index.js +23 -8
- package/src/components/template-details/style.scss +0 -5
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-details/template-part-area-selector.js +38 -0
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/index.js +1 -1
- 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,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getBlockSelectors = void 0;
|
|
6
7
|
exports.getLayoutStyles = getLayoutStyles;
|
|
7
|
-
exports.
|
|
8
|
+
exports.getNodesWithStyles = exports.getNodesWithSettings = void 0;
|
|
9
|
+
exports.getStylesDeclarations = getStylesDeclarations;
|
|
10
|
+
exports.toStyles = exports.toCustomProperties = void 0;
|
|
8
11
|
exports.toSvgFilters = toSvgFilters;
|
|
9
12
|
exports.useGlobalStylesOutput = useGlobalStylesOutput;
|
|
10
13
|
|
|
@@ -14,6 +17,8 @@ var _lodash = require("lodash");
|
|
|
14
17
|
|
|
15
18
|
var _blocks = require("@wordpress/blocks");
|
|
16
19
|
|
|
20
|
+
var _data = require("@wordpress/data");
|
|
21
|
+
|
|
17
22
|
var _styleEngine = require("@wordpress/style-engine");
|
|
18
23
|
|
|
19
24
|
var _blockEditor = require("@wordpress/block-editor");
|
|
@@ -35,12 +40,23 @@ var _hooks = require("./hooks");
|
|
|
35
40
|
/**
|
|
36
41
|
* Internal dependencies
|
|
37
42
|
*/
|
|
43
|
+
// List of block support features that can have their related styles
|
|
44
|
+
// generated under their own feature level selector rather than the block's.
|
|
45
|
+
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
46
|
+
__experimentalBorder: 'border',
|
|
47
|
+
color: 'color',
|
|
48
|
+
spacing: 'spacing',
|
|
49
|
+
typography: 'typography'
|
|
50
|
+
};
|
|
51
|
+
|
|
38
52
|
function compileStyleValue(uncompiledValue) {
|
|
53
|
+
var _uncompiledValue$star;
|
|
54
|
+
|
|
39
55
|
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
40
56
|
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
41
57
|
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
42
58
|
|
|
43
|
-
if (
|
|
59
|
+
if (uncompiledValue !== null && uncompiledValue !== void 0 && (_uncompiledValue$star = uncompiledValue.startsWith) !== null && _uncompiledValue$star !== void 0 && _uncompiledValue$star.call(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
|
|
44
60
|
const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
|
|
45
61
|
return `var(--wp--${variable})`;
|
|
46
62
|
}
|
|
@@ -51,13 +67,15 @@ function compileStyleValue(uncompiledValue) {
|
|
|
51
67
|
* Transform given preset tree into a set of style declarations.
|
|
52
68
|
*
|
|
53
69
|
* @param {Object} blockPresets
|
|
70
|
+
* @param {Object} mergedSettings Merged theme.json settings.
|
|
54
71
|
*
|
|
55
|
-
* @return {Array} An array of style declarations.
|
|
72
|
+
* @return {Array<Object>} An array of style declarations.
|
|
56
73
|
*/
|
|
57
74
|
|
|
58
75
|
|
|
59
76
|
function getPresetsDeclarations() {
|
|
60
77
|
let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
78
|
+
let mergedSettings = arguments.length > 1 ? arguments[1] : undefined;
|
|
61
79
|
return (0, _lodash.reduce)(_utils.PRESET_METADATA, (declarations, _ref) => {
|
|
62
80
|
let {
|
|
63
81
|
path,
|
|
@@ -69,10 +87,10 @@ function getPresetsDeclarations() {
|
|
|
69
87
|
['default', 'theme', 'custom'].forEach(origin => {
|
|
70
88
|
if (presetByOrigin[origin]) {
|
|
71
89
|
presetByOrigin[origin].forEach(value => {
|
|
72
|
-
if (valueKey) {
|
|
90
|
+
if (valueKey && !valueFunc) {
|
|
73
91
|
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${value[valueKey]}`);
|
|
74
92
|
} else if (valueFunc && typeof valueFunc === 'function') {
|
|
75
|
-
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${valueFunc(value)}`);
|
|
93
|
+
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${valueFunc(value, mergedSettings)}`);
|
|
76
94
|
}
|
|
77
95
|
});
|
|
78
96
|
}
|
|
@@ -160,7 +178,13 @@ function flattenTree() {
|
|
|
160
178
|
/**
|
|
161
179
|
* Transform given style tree into a set of style declarations.
|
|
162
180
|
*
|
|
163
|
-
* @param {Object}
|
|
181
|
+
* @param {Object} blockStyles Block styles.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} selector The selector these declarations should attach to.
|
|
184
|
+
*
|
|
185
|
+
* @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
|
|
186
|
+
*
|
|
187
|
+
* @param {Object} tree A theme.json tree containing layout definitions.
|
|
164
188
|
*
|
|
165
189
|
* @return {Array} An array of style declarations.
|
|
166
190
|
*/
|
|
@@ -168,19 +192,34 @@ function flattenTree() {
|
|
|
168
192
|
|
|
169
193
|
function getStylesDeclarations() {
|
|
170
194
|
let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
195
|
+
let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
196
|
+
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
197
|
+
let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
198
|
+
const isRoot = _utils.ROOT_BLOCK_SELECTOR === selector;
|
|
171
199
|
const output = (0, _lodash.reduce)(_blocks.__EXPERIMENTAL_STYLE_PROPERTY, (declarations, _ref5, key) => {
|
|
172
200
|
let {
|
|
173
201
|
value,
|
|
174
202
|
properties,
|
|
175
|
-
useEngine
|
|
203
|
+
useEngine,
|
|
204
|
+
rootOnly
|
|
176
205
|
} = _ref5;
|
|
206
|
+
|
|
207
|
+
if (rootOnly && !isRoot) {
|
|
208
|
+
return declarations;
|
|
209
|
+
}
|
|
210
|
+
|
|
177
211
|
const pathToValue = value;
|
|
178
212
|
|
|
179
213
|
if ((0, _lodash.first)(pathToValue) === 'elements' || useEngine) {
|
|
180
214
|
return declarations;
|
|
181
215
|
}
|
|
182
216
|
|
|
183
|
-
const styleValue = (0, _lodash.get)(blockStyles, pathToValue);
|
|
217
|
+
const styleValue = (0, _lodash.get)(blockStyles, pathToValue); // Root-level padding styles don't currently support strings with CSS shorthand values.
|
|
218
|
+
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
|
|
219
|
+
|
|
220
|
+
if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
|
|
221
|
+
return declarations;
|
|
222
|
+
}
|
|
184
223
|
|
|
185
224
|
if (!!properties && typeof styleValue !== 'string') {
|
|
186
225
|
Object.entries(properties).forEach(entry => {
|
|
@@ -192,7 +231,7 @@ function getStylesDeclarations() {
|
|
|
192
231
|
return;
|
|
193
232
|
}
|
|
194
233
|
|
|
195
|
-
const cssProperty = (0, _lodash.kebabCase)(name);
|
|
234
|
+
const cssProperty = name.startsWith('--') ? name : (0, _lodash.kebabCase)(name);
|
|
196
235
|
declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(styleValue, [prop]))}`);
|
|
197
236
|
});
|
|
198
237
|
} else if ((0, _lodash.get)(blockStyles, pathToValue, false)) {
|
|
@@ -206,8 +245,29 @@ function getStylesDeclarations() {
|
|
|
206
245
|
|
|
207
246
|
const extraRules = (0, _styleEngine.getCSSRules)(blockStyles);
|
|
208
247
|
extraRules.forEach(rule => {
|
|
248
|
+
var _ruleValue;
|
|
249
|
+
|
|
250
|
+
// Don't output padding properties if padding variables are set.
|
|
251
|
+
if (isRoot && useRootPaddingAlign && rule.key.startsWith('padding')) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
209
255
|
const cssProperty = rule.key.startsWith('--') ? rule.key : (0, _lodash.kebabCase)(rule.key);
|
|
210
|
-
|
|
256
|
+
let ruleValue = rule.value;
|
|
257
|
+
|
|
258
|
+
if (typeof ruleValue !== 'string' && (_ruleValue = ruleValue) !== null && _ruleValue !== void 0 && _ruleValue.ref) {
|
|
259
|
+
var _ruleValue2;
|
|
260
|
+
|
|
261
|
+
const refPath = ruleValue.ref.split('.');
|
|
262
|
+
ruleValue = (0, _lodash.get)(tree, refPath); // Presence of another ref indicates a reference to another dynamic value.
|
|
263
|
+
// Pointing to another dynamic value is not supported.
|
|
264
|
+
|
|
265
|
+
if (!ruleValue || !!((_ruleValue2 = ruleValue) !== null && _ruleValue2 !== void 0 && _ruleValue2.ref)) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
output.push(`${cssProperty}: ${ruleValue}`);
|
|
211
271
|
});
|
|
212
272
|
return output;
|
|
213
273
|
}
|
|
@@ -274,7 +334,15 @@ function getLayoutStyles(_ref6) {
|
|
|
274
334
|
}
|
|
275
335
|
|
|
276
336
|
if (declarations.length) {
|
|
277
|
-
|
|
337
|
+
let combinedSelector = '';
|
|
338
|
+
|
|
339
|
+
if (!hasBlockGapSupport) {
|
|
340
|
+
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
341
|
+
combinedSelector = selector === _utils.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) || ''})`;
|
|
342
|
+
} else {
|
|
343
|
+
combinedSelector = selector === _utils.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) || ''}`;
|
|
344
|
+
}
|
|
345
|
+
|
|
278
346
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
279
347
|
}
|
|
280
348
|
});
|
|
@@ -324,7 +392,7 @@ function getLayoutStyles(_ref6) {
|
|
|
324
392
|
}
|
|
325
393
|
|
|
326
394
|
const getNodesWithStyles = (tree, blockSelectors) => {
|
|
327
|
-
var _tree$
|
|
395
|
+
var _tree$styles3;
|
|
328
396
|
|
|
329
397
|
const nodes = [];
|
|
330
398
|
|
|
@@ -344,16 +412,20 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
344
412
|
});
|
|
345
413
|
}
|
|
346
414
|
|
|
347
|
-
(0, _lodash.forEach)(
|
|
348
|
-
|
|
415
|
+
(0, _lodash.forEach)(_blocks.__EXPERIMENTAL_ELEMENTS, (selector, name) => {
|
|
416
|
+
var _tree$styles;
|
|
417
|
+
|
|
418
|
+
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
419
|
+
var _tree$styles2;
|
|
420
|
+
|
|
349
421
|
nodes.push({
|
|
350
|
-
styles:
|
|
351
|
-
selector
|
|
422
|
+
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
|
|
423
|
+
selector
|
|
352
424
|
});
|
|
353
425
|
}
|
|
354
426
|
}); // Iterate over blocks: they can have styles & elements.
|
|
355
427
|
|
|
356
|
-
(0, _lodash.forEach)((_tree$
|
|
428
|
+
(0, _lodash.forEach)((_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks, (node, blockName) => {
|
|
357
429
|
var _blockSelectors$block;
|
|
358
430
|
|
|
359
431
|
const blockStyles = pickStyleKeys(node);
|
|
@@ -364,7 +436,8 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
364
436
|
fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
|
|
365
437
|
hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
|
|
366
438
|
selector: blockSelectors[blockName].selector,
|
|
367
|
-
styles: blockStyles
|
|
439
|
+
styles: blockStyles,
|
|
440
|
+
featureSelectors: blockSelectors[blockName].featureSelectors
|
|
368
441
|
});
|
|
369
442
|
}
|
|
370
443
|
|
|
@@ -451,7 +524,7 @@ const toCustomProperties = (tree, blockSelectors) => {
|
|
|
451
524
|
custom,
|
|
452
525
|
selector
|
|
453
526
|
} = _ref12;
|
|
454
|
-
const declarations = getPresetsDeclarations(presets);
|
|
527
|
+
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
455
528
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
456
529
|
|
|
457
530
|
if (customProps.length > 0) {
|
|
@@ -467,9 +540,17 @@ const toCustomProperties = (tree, blockSelectors) => {
|
|
|
467
540
|
|
|
468
541
|
exports.toCustomProperties = toCustomProperties;
|
|
469
542
|
|
|
470
|
-
const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport)
|
|
543
|
+
const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
|
|
544
|
+
var _tree$settings5, _tree$settings6;
|
|
545
|
+
|
|
546
|
+
let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
471
547
|
const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
|
|
472
548
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
549
|
+
const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.useRootPaddingAwareAlignments;
|
|
550
|
+
const {
|
|
551
|
+
contentSize,
|
|
552
|
+
wideSize
|
|
553
|
+
} = (tree === null || tree === void 0 ? void 0 : (_tree$settings6 = tree.settings) === null || _tree$settings6 === void 0 ? void 0 : _tree$settings6.layout) || {};
|
|
473
554
|
/*
|
|
474
555
|
* Reset default browser margin on the root body element.
|
|
475
556
|
* This is set on the root selector **before** generating the ruleset
|
|
@@ -479,15 +560,51 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
479
560
|
* @link https://github.com/WordPress/gutenberg/issues/36147.
|
|
480
561
|
*/
|
|
481
562
|
|
|
482
|
-
let ruleset = 'body {margin: 0;
|
|
563
|
+
let ruleset = 'body {margin: 0;';
|
|
564
|
+
|
|
565
|
+
if (contentSize) {
|
|
566
|
+
ruleset += ` --wp--style--global--content-size: ${contentSize};`;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (wideSize) {
|
|
570
|
+
ruleset += ` --wp--style--global--wide-size: ${wideSize};`;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (useRootPaddingAlign) {
|
|
574
|
+
ruleset += '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);';
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
ruleset += '}';
|
|
483
578
|
nodesWithStyles.forEach(_ref13 => {
|
|
484
579
|
let {
|
|
485
580
|
selector,
|
|
486
581
|
duotoneSelector,
|
|
487
582
|
styles,
|
|
488
583
|
fallbackGapValue,
|
|
489
|
-
hasLayoutSupport
|
|
584
|
+
hasLayoutSupport,
|
|
585
|
+
featureSelectors
|
|
490
586
|
} = _ref13;
|
|
587
|
+
|
|
588
|
+
// Process styles for block support features with custom feature level
|
|
589
|
+
// CSS selectors set.
|
|
590
|
+
if (featureSelectors) {
|
|
591
|
+
Object.entries(featureSelectors).forEach(_ref14 => {
|
|
592
|
+
let [featureName, featureSelector] = _ref14;
|
|
593
|
+
|
|
594
|
+
if (styles !== null && styles !== void 0 && styles[featureName]) {
|
|
595
|
+
const featureStyles = {
|
|
596
|
+
[featureName]: styles[featureName]
|
|
597
|
+
};
|
|
598
|
+
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
599
|
+
delete styles[featureName];
|
|
600
|
+
|
|
601
|
+
if (!!featureDeclarations.length) {
|
|
602
|
+
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
491
608
|
const duotoneStyles = {};
|
|
492
609
|
|
|
493
610
|
if (styles !== null && styles !== void 0 && styles.filter) {
|
|
@@ -499,15 +616,13 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
499
616
|
if (duotoneSelector) {
|
|
500
617
|
const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
|
|
501
618
|
|
|
502
|
-
if (duotoneDeclarations.length
|
|
503
|
-
|
|
619
|
+
if (duotoneDeclarations.length > 0) {
|
|
620
|
+
ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
|
|
504
621
|
}
|
|
505
|
-
|
|
506
|
-
ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
|
|
507
622
|
} // Process blockGap and layout styles.
|
|
508
623
|
|
|
509
624
|
|
|
510
|
-
if (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport) {
|
|
625
|
+
if (!disableLayoutStyles && (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
|
|
511
626
|
ruleset += getLayoutStyles({
|
|
512
627
|
tree,
|
|
513
628
|
style: styles,
|
|
@@ -519,28 +634,28 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
519
634
|
} // Process the remaining block styles (they use either normal block class or __experimentalSelector).
|
|
520
635
|
|
|
521
636
|
|
|
522
|
-
const declarations = getStylesDeclarations(styles);
|
|
637
|
+
const declarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree);
|
|
523
638
|
|
|
524
639
|
if (declarations !== null && declarations !== void 0 && declarations.length) {
|
|
525
640
|
ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
|
|
526
641
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
527
642
|
|
|
528
643
|
|
|
529
|
-
const pseudoSelectorStyles = Object.entries(styles).filter(
|
|
530
|
-
let [key] =
|
|
644
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref15 => {
|
|
645
|
+
let [key] = _ref15;
|
|
531
646
|
return key.startsWith(':');
|
|
532
647
|
});
|
|
533
648
|
|
|
534
649
|
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
535
|
-
pseudoSelectorStyles.forEach(
|
|
536
|
-
let [pseudoKey, pseudoStyle] =
|
|
650
|
+
pseudoSelectorStyles.forEach(_ref16 => {
|
|
651
|
+
let [pseudoKey, pseudoStyle] = _ref16;
|
|
537
652
|
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
538
653
|
|
|
539
654
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
540
655
|
return;
|
|
541
656
|
} // `selector` maybe provided in a form
|
|
542
657
|
// where block level selectors have sub element
|
|
543
|
-
// selectors appended to them as a comma
|
|
658
|
+
// selectors appended to them as a comma separated
|
|
544
659
|
// string.
|
|
545
660
|
// e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;
|
|
546
661
|
// Split and append pseudo selector to create
|
|
@@ -561,19 +676,19 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
561
676
|
ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
|
|
562
677
|
|
|
563
678
|
if (hasBlockGapSupport) {
|
|
564
|
-
var _tree$
|
|
679
|
+
var _tree$styles4, _tree$styles4$spacing;
|
|
565
680
|
|
|
566
681
|
// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
|
|
567
|
-
const gapValue = (0, _blockEditor.__experimentalGetGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$
|
|
682
|
+
const gapValue = (0, _blockEditor.__experimentalGetGapCSSValue)(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';
|
|
568
683
|
ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
|
|
569
684
|
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
570
685
|
}
|
|
571
686
|
|
|
572
|
-
nodesWithSettings.forEach(
|
|
687
|
+
nodesWithSettings.forEach(_ref17 => {
|
|
573
688
|
let {
|
|
574
689
|
selector,
|
|
575
690
|
presets
|
|
576
|
-
} =
|
|
691
|
+
} = _ref17;
|
|
577
692
|
|
|
578
693
|
if (_utils.ROOT_BLOCK_SELECTOR === selector) {
|
|
579
694
|
// Do not add extra specificity for top-level classes.
|
|
@@ -593,10 +708,10 @@ exports.toStyles = toStyles;
|
|
|
593
708
|
|
|
594
709
|
function toSvgFilters(tree, blockSelectors) {
|
|
595
710
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
596
|
-
return nodesWithSettings.flatMap(
|
|
711
|
+
return nodesWithSettings.flatMap(_ref18 => {
|
|
597
712
|
let {
|
|
598
713
|
presets
|
|
599
|
-
} =
|
|
714
|
+
} = _ref18;
|
|
600
715
|
return getPresetsSvgFilters(presets);
|
|
601
716
|
});
|
|
602
717
|
}
|
|
@@ -610,10 +725,23 @@ const getBlockSelectors = blockTypes => {
|
|
|
610
725
|
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('/', '-');
|
|
611
726
|
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;
|
|
612
727
|
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
|
|
613
|
-
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;
|
|
728
|
+
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.
|
|
729
|
+
|
|
730
|
+
const featureSelectors = {};
|
|
731
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref19 => {
|
|
732
|
+
var _blockType$supports5, _blockType$supports5$;
|
|
733
|
+
|
|
734
|
+
let [featureKey, featureName] = _ref19;
|
|
735
|
+
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;
|
|
736
|
+
|
|
737
|
+
if (featureSelector) {
|
|
738
|
+
featureSelectors[featureName] = (0, _utils.scopeSelector)(selector, featureSelector);
|
|
739
|
+
}
|
|
740
|
+
});
|
|
614
741
|
result[name] = {
|
|
615
742
|
duotoneSelector,
|
|
616
743
|
fallbackGapValue,
|
|
744
|
+
featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : undefined,
|
|
617
745
|
hasLayoutSupport,
|
|
618
746
|
name,
|
|
619
747
|
selector
|
|
@@ -622,10 +750,9 @@ const getBlockSelectors = blockTypes => {
|
|
|
622
750
|
return result;
|
|
623
751
|
};
|
|
624
752
|
|
|
753
|
+
exports.getBlockSelectors = getBlockSelectors;
|
|
754
|
+
|
|
625
755
|
function useGlobalStylesOutput() {
|
|
626
|
-
const [stylesheets, setStylesheets] = (0, _element.useState)([]);
|
|
627
|
-
const [settings, setSettings] = (0, _element.useState)({});
|
|
628
|
-
const [svgFilters, setSvgFilters] = (0, _element.useState)({});
|
|
629
756
|
const {
|
|
630
757
|
merged: mergedConfig
|
|
631
758
|
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
@@ -633,25 +760,29 @@ function useGlobalStylesOutput() {
|
|
|
633
760
|
const hasBlockGapSupport = blockGap !== null;
|
|
634
761
|
const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
|
|
635
762
|
|
|
636
|
-
(0,
|
|
763
|
+
const disableLayoutStyles = (0, _data.useSelect)(select => {
|
|
764
|
+
const {
|
|
765
|
+
getSettings
|
|
766
|
+
} = select(_blockEditor.store);
|
|
767
|
+
return !!getSettings().disableLayoutStyles;
|
|
768
|
+
});
|
|
769
|
+
return (0, _element.useMemo)(() => {
|
|
637
770
|
if (!(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.styles) || !(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.settings)) {
|
|
638
|
-
return;
|
|
771
|
+
return [];
|
|
639
772
|
}
|
|
640
773
|
|
|
641
774
|
const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)());
|
|
642
775
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
643
|
-
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport);
|
|
776
|
+
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
644
777
|
const filters = toSvgFilters(mergedConfig, blockSelectors);
|
|
645
|
-
|
|
778
|
+
const stylesheets = [{
|
|
646
779
|
css: customProperties,
|
|
647
780
|
isGlobalStyles: true
|
|
648
781
|
}, {
|
|
649
782
|
css: globalStyles,
|
|
650
783
|
isGlobalStyles: true
|
|
651
|
-
}]
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig]);
|
|
655
|
-
return [stylesheets, settings, svgFilters, hasBlockGapSupport];
|
|
784
|
+
}];
|
|
785
|
+
return [stylesheets, mergedConfig.settings, filters];
|
|
786
|
+
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
656
787
|
}
|
|
657
788
|
//# sourceMappingURL=use-global-styles-output.js.map
|