@wordpress/block-editor 11.6.0 → 11.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 +4 -0
- package/README.md +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +53 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +18 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -35
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +160 -86
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +0 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +25 -76
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +51 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +8 -35
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +161 -87
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +0 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +23 -73
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-style/style-rtl.css +26 -6
- package/build-style/style.css +26 -6
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +80 -0
- package/src/components/global-styles/index.js +2 -1
- package/src/components/global-styles/test/use-global-styles-output.js +30 -1
- package/src/components/global-styles/typography-panel.js +26 -51
- package/src/components/global-styles/use-global-styles-output.js +163 -80
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +0 -1
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +0 -1
- package/src/hooks/utils.js +27 -70
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +2 -0
- package/src/utils/object.js +69 -0
- package/src/utils/test/object.js +107 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
|
@@ -23,6 +23,8 @@ var _styleEngine = require("@wordpress/style-engine");
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("./utils");
|
|
25
25
|
|
|
26
|
+
var _getBlockCssSelector = require("./get-block-css-selector");
|
|
27
|
+
|
|
26
28
|
var _typographyUtils = require("./typography-utils");
|
|
27
29
|
|
|
28
30
|
var _context = require("./context");
|
|
@@ -157,10 +159,10 @@ function getPresetsSvgFilters() {
|
|
|
157
159
|
return _utils.PRESET_METADATA.filter( // Duotone are the only type of filters for now.
|
|
158
160
|
metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
|
|
159
161
|
const presetByOrigin = (0, _lodash.get)(blockPresets, metadata.path, {});
|
|
160
|
-
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0, _element.createElement)(_components.PresetDuotoneFilter, {
|
|
162
|
+
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0, _element.renderToString)((0, _element.createElement)(_components.PresetDuotoneFilter, {
|
|
161
163
|
preset: preset,
|
|
162
164
|
key: preset.slug
|
|
163
|
-
})));
|
|
165
|
+
})))).join('');
|
|
164
166
|
});
|
|
165
167
|
}
|
|
166
168
|
|
|
@@ -201,6 +203,76 @@ function concatFeatureVariationSelectorString(featureSelector, styleVariationSel
|
|
|
201
203
|
});
|
|
202
204
|
return combinedSelectors.join(', ');
|
|
203
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Generate style declarations for a block's custom feature and subfeature
|
|
208
|
+
* selectors.
|
|
209
|
+
*
|
|
210
|
+
* NOTE: The passed `styles` object will be mutated by this function.
|
|
211
|
+
*
|
|
212
|
+
* @param {Object} selectors Custom selectors object for a block.
|
|
213
|
+
* @param {Object} styles A block's styles object.
|
|
214
|
+
*
|
|
215
|
+
* @return {Object} Style declarations.
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
const getFeatureDeclarations = (selectors, styles) => {
|
|
220
|
+
const declarations = {};
|
|
221
|
+
Object.entries(selectors).forEach(_ref5 => {
|
|
222
|
+
let [feature, selector] = _ref5;
|
|
223
|
+
|
|
224
|
+
// We're only processing features/subfeatures that have styles.
|
|
225
|
+
if (feature === 'root' || !(styles !== null && styles !== void 0 && styles[feature])) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const isShorthand = typeof selector === 'string'; // If we have a selector object instead of shorthand process it.
|
|
230
|
+
|
|
231
|
+
if (!isShorthand) {
|
|
232
|
+
Object.entries(selector).forEach(_ref6 => {
|
|
233
|
+
let [subfeature, subfeatureSelector] = _ref6;
|
|
234
|
+
|
|
235
|
+
// Don't process root feature selector yet or any
|
|
236
|
+
// subfeature that doesn't have a style.
|
|
237
|
+
if (subfeature === 'root' || !(styles !== null && styles !== void 0 && styles[feature][subfeature])) {
|
|
238
|
+
return;
|
|
239
|
+
} // Create a temporary styles object and build
|
|
240
|
+
// declarations for subfeature.
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
const subfeatureStyles = {
|
|
244
|
+
[feature]: {
|
|
245
|
+
[subfeature]: styles[feature][subfeature]
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
const newDeclarations = getStylesDeclarations(subfeatureStyles); // Merge new declarations in with any others that
|
|
249
|
+
// share the same selector.
|
|
250
|
+
|
|
251
|
+
declarations[subfeatureSelector] = [...(declarations[subfeatureSelector] || []), ...newDeclarations]; // Remove the subfeature's style now it will be
|
|
252
|
+
// included under its own selector not the block's.
|
|
253
|
+
|
|
254
|
+
delete styles[feature][subfeature];
|
|
255
|
+
});
|
|
256
|
+
} // Now subfeatures have been processed and removed, we can
|
|
257
|
+
// process root, or shorthand, feature selectors.
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if (isShorthand || selector.root) {
|
|
261
|
+
const featureSelector = isShorthand ? selector : selector.root; // Create temporary style object and build declarations for feature.
|
|
262
|
+
|
|
263
|
+
const featureStyles = {
|
|
264
|
+
[feature]: styles[feature]
|
|
265
|
+
};
|
|
266
|
+
const newDeclarations = getStylesDeclarations(featureStyles); // Merge new declarations with any others that share the selector.
|
|
267
|
+
|
|
268
|
+
declarations[featureSelector] = [...(declarations[featureSelector] || []), ...newDeclarations]; // Remove the feature from the block's styles now as it will be
|
|
269
|
+
// included under its own selector not the block's.
|
|
270
|
+
|
|
271
|
+
delete styles[feature];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return declarations;
|
|
275
|
+
};
|
|
204
276
|
/**
|
|
205
277
|
* Transform given style tree into a set of style declarations.
|
|
206
278
|
*
|
|
@@ -222,13 +294,13 @@ function getStylesDeclarations() {
|
|
|
222
294
|
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
223
295
|
let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
224
296
|
const isRoot = _utils.ROOT_BLOCK_SELECTOR === selector;
|
|
225
|
-
const output = Object.entries(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations,
|
|
297
|
+
const output = Object.entries(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations, _ref7) => {
|
|
226
298
|
let [key, {
|
|
227
299
|
value,
|
|
228
300
|
properties,
|
|
229
301
|
useEngine,
|
|
230
302
|
rootOnly
|
|
231
|
-
}] =
|
|
303
|
+
}] = _ref7;
|
|
232
304
|
|
|
233
305
|
if (rootOnly && !isRoot) {
|
|
234
306
|
return declarations;
|
|
@@ -328,7 +400,7 @@ function getStylesDeclarations() {
|
|
|
328
400
|
*/
|
|
329
401
|
|
|
330
402
|
|
|
331
|
-
function getLayoutStyles(
|
|
403
|
+
function getLayoutStyles(_ref8) {
|
|
332
404
|
var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
|
|
333
405
|
|
|
334
406
|
let {
|
|
@@ -338,7 +410,7 @@ function getLayoutStyles(_ref6) {
|
|
|
338
410
|
hasBlockGapSupport,
|
|
339
411
|
hasFallbackGapSupport,
|
|
340
412
|
fallbackGapValue
|
|
341
|
-
} =
|
|
413
|
+
} = _ref8;
|
|
342
414
|
let ruleset = '';
|
|
343
415
|
let gapValue = hasBlockGapSupport ? (0, _gap.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,
|
|
344
416
|
// and use a fallback value if one is provided for the current block.
|
|
@@ -352,12 +424,12 @@ function getLayoutStyles(_ref6) {
|
|
|
352
424
|
}
|
|
353
425
|
|
|
354
426
|
if (gapValue && 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) {
|
|
355
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
427
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
|
|
356
428
|
let {
|
|
357
429
|
className,
|
|
358
430
|
name,
|
|
359
431
|
spacingStyles
|
|
360
|
-
} =
|
|
432
|
+
} = _ref9;
|
|
361
433
|
|
|
362
434
|
// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
|
|
363
435
|
if (!hasBlockGapSupport && 'flex' !== name) {
|
|
@@ -369,8 +441,8 @@ function getLayoutStyles(_ref6) {
|
|
|
369
441
|
const declarations = [];
|
|
370
442
|
|
|
371
443
|
if (spacingStyle.rules) {
|
|
372
|
-
Object.entries(spacingStyle.rules).forEach(
|
|
373
|
-
let [cssProperty, cssValue] =
|
|
444
|
+
Object.entries(spacingStyle.rules).forEach(_ref10 => {
|
|
445
|
+
let [cssProperty, cssValue] = _ref10;
|
|
374
446
|
declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
|
|
375
447
|
});
|
|
376
448
|
}
|
|
@@ -399,12 +471,12 @@ function getLayoutStyles(_ref6) {
|
|
|
399
471
|
|
|
400
472
|
if (selector === _utils.ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings3 = tree.settings) !== null && _tree$settings3 !== void 0 && (_tree$settings3$layou = _tree$settings3.layout) !== null && _tree$settings3$layou !== void 0 && _tree$settings3$layou.definitions) {
|
|
401
473
|
const validDisplayModes = ['block', 'flex', 'grid'];
|
|
402
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
474
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref11 => {
|
|
403
475
|
let {
|
|
404
476
|
className,
|
|
405
477
|
displayMode,
|
|
406
478
|
baseStyles
|
|
407
|
-
} =
|
|
479
|
+
} = _ref11;
|
|
408
480
|
|
|
409
481
|
if (displayMode && validDisplayModes.includes(displayMode)) {
|
|
410
482
|
ruleset += `${selector} .${className} { display:${displayMode}; }`;
|
|
@@ -415,8 +487,8 @@ function getLayoutStyles(_ref6) {
|
|
|
415
487
|
const declarations = [];
|
|
416
488
|
|
|
417
489
|
if (baseStyle.rules) {
|
|
418
|
-
Object.entries(baseStyle.rules).forEach(
|
|
419
|
-
let [cssProperty, cssValue] =
|
|
490
|
+
Object.entries(baseStyle.rules).forEach(_ref12 => {
|
|
491
|
+
let [cssProperty, cssValue] = _ref12;
|
|
420
492
|
declarations.push(`${cssProperty}: ${cssValue}`);
|
|
421
493
|
});
|
|
422
494
|
}
|
|
@@ -442,8 +514,8 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
442
514
|
return nodes;
|
|
443
515
|
}
|
|
444
516
|
|
|
445
|
-
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(
|
|
446
|
-
let [key] =
|
|
517
|
+
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref13 => {
|
|
518
|
+
let [key] = _ref13;
|
|
447
519
|
return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
|
|
448
520
|
})); // Top-level.
|
|
449
521
|
|
|
@@ -457,10 +529,10 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
457
529
|
});
|
|
458
530
|
}
|
|
459
531
|
|
|
460
|
-
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(
|
|
532
|
+
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(_ref14 => {
|
|
461
533
|
var _tree$styles, _tree$styles$elements;
|
|
462
534
|
|
|
463
|
-
let [name, selector] =
|
|
535
|
+
let [name, selector] = _ref14;
|
|
464
536
|
|
|
465
537
|
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && (_tree$styles$elements = _tree$styles.elements) !== null && _tree$styles$elements !== void 0 && _tree$styles$elements[name])) {
|
|
466
538
|
var _tree$styles2, _tree$styles2$element;
|
|
@@ -472,10 +544,10 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
472
544
|
}
|
|
473
545
|
}); // Iterate over blocks: they can have styles & elements.
|
|
474
546
|
|
|
475
|
-
Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(
|
|
547
|
+
Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(_ref15 => {
|
|
476
548
|
var _blockSelectors$block, _node$elements;
|
|
477
549
|
|
|
478
|
-
let [blockName, node] =
|
|
550
|
+
let [blockName, node] = _ref15;
|
|
479
551
|
const blockStyles = pickStyleKeys(node);
|
|
480
552
|
|
|
481
553
|
if (node !== null && node !== void 0 && node.variations) {
|
|
@@ -500,8 +572,8 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
500
572
|
});
|
|
501
573
|
}
|
|
502
574
|
|
|
503
|
-
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(
|
|
504
|
-
let [elementName, value] =
|
|
575
|
+
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref16 => {
|
|
576
|
+
let [elementName, value] = _ref16;
|
|
505
577
|
|
|
506
578
|
if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(_blocks.__EXPERIMENTAL_ELEMENTS !== null && _blocks.__EXPERIMENTAL_ELEMENTS !== void 0 && _blocks.__EXPERIMENTAL_ELEMENTS[elementName])) {
|
|
507
579
|
var _blockSelectors$block3;
|
|
@@ -534,10 +606,10 @@ const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
534
606
|
const pickPresets = treeToPickFrom => {
|
|
535
607
|
const presets = {};
|
|
536
608
|
|
|
537
|
-
_utils.PRESET_METADATA.forEach(
|
|
609
|
+
_utils.PRESET_METADATA.forEach(_ref17 => {
|
|
538
610
|
let {
|
|
539
611
|
path
|
|
540
|
-
} =
|
|
612
|
+
} = _ref17;
|
|
541
613
|
const value = (0, _lodash.get)(treeToPickFrom, path, false);
|
|
542
614
|
|
|
543
615
|
if (value !== false) {
|
|
@@ -561,8 +633,8 @@ const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
561
633
|
} // Blocks.
|
|
562
634
|
|
|
563
635
|
|
|
564
|
-
Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(
|
|
565
|
-
let [blockName, node] =
|
|
636
|
+
Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref18 => {
|
|
637
|
+
let [blockName, node] = _ref18;
|
|
566
638
|
const blockPresets = pickPresets(node);
|
|
567
639
|
const blockCustom = node.custom;
|
|
568
640
|
|
|
@@ -584,12 +656,12 @@ exports.getNodesWithSettings = getNodesWithSettings;
|
|
|
584
656
|
const toCustomProperties = (tree, blockSelectors) => {
|
|
585
657
|
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
586
658
|
let ruleset = '';
|
|
587
|
-
settings.forEach(
|
|
659
|
+
settings.forEach(_ref19 => {
|
|
588
660
|
let {
|
|
589
661
|
presets,
|
|
590
662
|
custom,
|
|
591
663
|
selector
|
|
592
|
-
} =
|
|
664
|
+
} = _ref19;
|
|
593
665
|
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
594
666
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
595
667
|
|
|
@@ -651,7 +723,7 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
651
723
|
}
|
|
652
724
|
|
|
653
725
|
ruleset += '}';
|
|
654
|
-
nodesWithStyles.forEach(
|
|
726
|
+
nodesWithStyles.forEach(_ref20 => {
|
|
655
727
|
let {
|
|
656
728
|
selector,
|
|
657
729
|
duotoneSelector,
|
|
@@ -660,54 +732,43 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
660
732
|
hasLayoutSupport,
|
|
661
733
|
featureSelectors,
|
|
662
734
|
styleVariationSelectors
|
|
663
|
-
} =
|
|
735
|
+
} = _ref20;
|
|
664
736
|
|
|
665
737
|
// Process styles for block support features with custom feature level
|
|
666
738
|
// CSS selectors set.
|
|
667
739
|
if (featureSelectors) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
676
|
-
delete styles[featureName];
|
|
677
|
-
|
|
678
|
-
if (!!featureDeclarations.length) {
|
|
679
|
-
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
680
|
-
}
|
|
740
|
+
const featureDeclarations = getFeatureDeclarations(featureSelectors, styles);
|
|
741
|
+
Object.entries(featureDeclarations).forEach(_ref21 => {
|
|
742
|
+
let [cssSelector, declarations] = _ref21;
|
|
743
|
+
|
|
744
|
+
if (!!declarations.length) {
|
|
745
|
+
const rules = declarations.join(';');
|
|
746
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
681
747
|
}
|
|
682
748
|
});
|
|
683
749
|
}
|
|
684
750
|
|
|
685
751
|
if (styleVariationSelectors) {
|
|
686
|
-
Object.entries(styleVariationSelectors).forEach(
|
|
752
|
+
Object.entries(styleVariationSelectors).forEach(_ref22 => {
|
|
687
753
|
var _styles$variations;
|
|
688
754
|
|
|
689
|
-
let [styleVariationName, styleVariationSelector] =
|
|
755
|
+
let [styleVariationName, styleVariationSelector] = _ref22;
|
|
690
756
|
|
|
691
757
|
if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
|
|
692
758
|
var _styles$variations3;
|
|
693
759
|
|
|
694
760
|
// If the block uses any custom selectors for block support, add those first.
|
|
695
761
|
if (featureSelectors) {
|
|
696
|
-
|
|
697
|
-
var _styles$variations2, _styles$variations2$s;
|
|
698
|
-
|
|
699
|
-
let [featureName, featureSelector] = _ref21;
|
|
762
|
+
var _styles$variations2;
|
|
700
763
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
};
|
|
705
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
706
|
-
delete styles.variations[styleVariationName][featureName];
|
|
764
|
+
const featureDeclarations = getFeatureDeclarations(featureSelectors, styles === null || styles === void 0 ? void 0 : (_styles$variations2 = styles.variations) === null || _styles$variations2 === void 0 ? void 0 : _styles$variations2[styleVariationName]);
|
|
765
|
+
Object.entries(featureDeclarations).forEach(_ref23 => {
|
|
766
|
+
let [baseSelector, declarations] = _ref23;
|
|
707
767
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
768
|
+
if (!!declarations.length) {
|
|
769
|
+
const cssSelector = concatFeatureVariationSelectorString(baseSelector, styleVariationSelector);
|
|
770
|
+
const rules = declarations.join(';');
|
|
771
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
711
772
|
}
|
|
712
773
|
});
|
|
713
774
|
} // Otherwise add regular selectors.
|
|
@@ -758,14 +819,14 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
758
819
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
759
820
|
|
|
760
821
|
|
|
761
|
-
const pseudoSelectorStyles = Object.entries(styles).filter(
|
|
762
|
-
let [key] =
|
|
822
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref24 => {
|
|
823
|
+
let [key] = _ref24;
|
|
763
824
|
return key.startsWith(':');
|
|
764
825
|
});
|
|
765
826
|
|
|
766
827
|
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
767
|
-
pseudoSelectorStyles.forEach(
|
|
768
|
-
let [pseudoKey, pseudoStyle] =
|
|
828
|
+
pseudoSelectorStyles.forEach(_ref25 => {
|
|
829
|
+
let [pseudoKey, pseudoStyle] = _ref25;
|
|
769
830
|
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
770
831
|
|
|
771
832
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
@@ -801,11 +862,11 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
801
862
|
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
802
863
|
}
|
|
803
864
|
|
|
804
|
-
nodesWithSettings.forEach(
|
|
865
|
+
nodesWithSettings.forEach(_ref26 => {
|
|
805
866
|
let {
|
|
806
867
|
selector,
|
|
807
868
|
presets
|
|
808
|
-
} =
|
|
869
|
+
} = _ref26;
|
|
809
870
|
|
|
810
871
|
if (_utils.ROOT_BLOCK_SELECTOR === selector) {
|
|
811
872
|
// Do not add extra specificity for top-level classes.
|
|
@@ -825,24 +886,43 @@ exports.toStyles = toStyles;
|
|
|
825
886
|
|
|
826
887
|
function toSvgFilters(tree, blockSelectors) {
|
|
827
888
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
828
|
-
return nodesWithSettings.flatMap(
|
|
889
|
+
return nodesWithSettings.flatMap(_ref27 => {
|
|
829
890
|
let {
|
|
830
891
|
presets
|
|
831
|
-
} =
|
|
892
|
+
} = _ref27;
|
|
832
893
|
return getPresetsSvgFilters(presets);
|
|
833
894
|
});
|
|
834
895
|
}
|
|
835
896
|
|
|
897
|
+
const getSelectorsConfig = (blockType, rootSelector) => {
|
|
898
|
+
if (!(0, _lodash.isEmpty)(blockType === null || blockType === void 0 ? void 0 : blockType.selectors)) {
|
|
899
|
+
return blockType.selectors;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const config = {
|
|
903
|
+
root: rootSelector
|
|
904
|
+
};
|
|
905
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref28 => {
|
|
906
|
+
let [featureKey, featureName] = _ref28;
|
|
907
|
+
const featureSelector = (0, _getBlockCssSelector.getBlockCSSSelector)(blockType, featureKey);
|
|
908
|
+
|
|
909
|
+
if (featureSelector) {
|
|
910
|
+
config[featureName] = featureSelector;
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
return config;
|
|
914
|
+
};
|
|
915
|
+
|
|
836
916
|
const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
837
917
|
const result = {};
|
|
838
918
|
blockTypes.forEach(blockType => {
|
|
839
|
-
var _blockType$supports
|
|
919
|
+
var _blockType$supports, _blockType$supports2, _blockType$supports2$, _blockType$supports2$2;
|
|
840
920
|
|
|
841
921
|
const name = blockType.name;
|
|
842
|
-
const selector = (
|
|
843
|
-
const duotoneSelector = (
|
|
844
|
-
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$
|
|
845
|
-
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$
|
|
922
|
+
const selector = (0, _getBlockCssSelector.getBlockCSSSelector)(blockType, 'root');
|
|
923
|
+
const duotoneSelector = (0, _getBlockCssSelector.getBlockCSSSelector)(blockType, 'filter.duotone');
|
|
924
|
+
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && _blockType$supports.__experimentalLayout);
|
|
925
|
+
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.spacing) === null || _blockType$supports2$ === void 0 ? void 0 : (_blockType$supports2$2 = _blockType$supports2$.blockGap) === null || _blockType$supports2$2 === void 0 ? void 0 : _blockType$supports2$2.__experimentalDefault;
|
|
846
926
|
const blockStyleVariations = getBlockStyles(name);
|
|
847
927
|
const styleVariationSelectors = {};
|
|
848
928
|
|
|
@@ -854,17 +934,7 @@ const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
|
854
934
|
} // For each block support feature add any custom selectors.
|
|
855
935
|
|
|
856
936
|
|
|
857
|
-
const featureSelectors =
|
|
858
|
-
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
|
|
859
|
-
var _blockType$supports5, _blockType$supports5$;
|
|
860
|
-
|
|
861
|
-
let [featureKey, featureName] = _ref26;
|
|
862
|
-
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;
|
|
863
|
-
|
|
864
|
-
if (featureSelector) {
|
|
865
|
-
featureSelectors[featureName] = (0, _utils.scopeSelector)(selector, featureSelector);
|
|
866
|
-
}
|
|
867
|
-
});
|
|
937
|
+
const featureSelectors = getSelectorsConfig(blockType, selector);
|
|
868
938
|
result[name] = {
|
|
869
939
|
duotoneSelector,
|
|
870
940
|
fallbackGapValue,
|
|
@@ -951,8 +1021,8 @@ function useGlobalStylesOutput() {
|
|
|
951
1021
|
const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)(), getBlockStyles);
|
|
952
1022
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
953
1023
|
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
954
|
-
const
|
|
955
|
-
const
|
|
1024
|
+
const svgs = toSvgFilters(mergedConfig, blockSelectors);
|
|
1025
|
+
const styles = [{
|
|
956
1026
|
css: customProperties,
|
|
957
1027
|
isGlobalStyles: true
|
|
958
1028
|
}, {
|
|
@@ -962,6 +1032,10 @@ function useGlobalStylesOutput() {
|
|
|
962
1032
|
{
|
|
963
1033
|
css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
|
|
964
1034
|
isGlobalStyles: true
|
|
1035
|
+
}, {
|
|
1036
|
+
assets: svgs,
|
|
1037
|
+
__unstableType: 'svg',
|
|
1038
|
+
isGlobalStyles: true
|
|
965
1039
|
}]; // Loop through the blocks to check if there are custom CSS values.
|
|
966
1040
|
// If there are, get the block selector and push the selector together with
|
|
967
1041
|
// the CSS value to the 'stylesheets' array.
|
|
@@ -973,13 +1047,13 @@ function useGlobalStylesOutput() {
|
|
|
973
1047
|
var _mergedConfig$styles$3;
|
|
974
1048
|
|
|
975
1049
|
const selector = blockSelectors[blockType.name].selector;
|
|
976
|
-
|
|
1050
|
+
styles.push({
|
|
977
1051
|
css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
|
|
978
1052
|
isGlobalStyles: true
|
|
979
1053
|
});
|
|
980
1054
|
}
|
|
981
1055
|
});
|
|
982
|
-
return [
|
|
1056
|
+
return [styles, mergedConfig.settings];
|
|
983
1057
|
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
984
1058
|
}
|
|
985
1059
|
//# sourceMappingURL=use-global-styles-output.js.map
|