Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: block-editor.js
ruleset += pseudoRule;
[34500] Fix | Delete
});
[34501] Fix | Delete
}
[34502] Fix | Delete
});
[34503] Fix | Delete
}
[34504] Fix | Delete
if (options.layoutStyles) {
[34505] Fix | Delete
/* Add alignment / layout styles */
[34506] Fix | Delete
ruleset = ruleset + '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
[34507] Fix | Delete
ruleset = ruleset + '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
[34508] Fix | Delete
ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
[34509] Fix | Delete
}
[34510] Fix | Delete
if (options.blockGap && hasBlockGapSupport) {
[34511] Fix | Delete
// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
[34512] Fix | Delete
const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || '0.5em';
[34513] Fix | Delete
ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: ${gapValue}; margin-block-end: 0; }`;
[34514] Fix | Delete
ruleset = ruleset + ':root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }';
[34515] Fix | Delete
ruleset = ruleset + ':root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }';
[34516] Fix | Delete
}
[34517] Fix | Delete
if (options.presets) {
[34518] Fix | Delete
nodesWithSettings.forEach(({
[34519] Fix | Delete
selector,
[34520] Fix | Delete
presets
[34521] Fix | Delete
}) => {
[34522] Fix | Delete
if (ROOT_BLOCK_SELECTOR === selector || ROOT_CSS_PROPERTIES_SELECTOR === selector) {
[34523] Fix | Delete
// Do not add extra specificity for top-level classes.
[34524] Fix | Delete
selector = '';
[34525] Fix | Delete
}
[34526] Fix | Delete
const classes = getPresetsClasses(selector, presets);
[34527] Fix | Delete
if (classes.length > 0) {
[34528] Fix | Delete
ruleset += classes;
[34529] Fix | Delete
}
[34530] Fix | Delete
});
[34531] Fix | Delete
}
[34532] Fix | Delete
return ruleset;
[34533] Fix | Delete
};
[34534] Fix | Delete
function toSvgFilters(tree, blockSelectors) {
[34535] Fix | Delete
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
[34536] Fix | Delete
return nodesWithSettings.flatMap(({
[34537] Fix | Delete
presets
[34538] Fix | Delete
}) => {
[34539] Fix | Delete
return getPresetsSvgFilters(presets);
[34540] Fix | Delete
});
[34541] Fix | Delete
}
[34542] Fix | Delete
const getSelectorsConfig = (blockType, rootSelector) => {
[34543] Fix | Delete
if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) {
[34544] Fix | Delete
return blockType.selectors;
[34545] Fix | Delete
}
[34546] Fix | Delete
const config = {
[34547] Fix | Delete
root: rootSelector
[34548] Fix | Delete
};
[34549] Fix | Delete
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(([featureKey, featureName]) => {
[34550] Fix | Delete
const featureSelector = getBlockCSSSelector(blockType, featureKey);
[34551] Fix | Delete
if (featureSelector) {
[34552] Fix | Delete
config[featureName] = featureSelector;
[34553] Fix | Delete
}
[34554] Fix | Delete
});
[34555] Fix | Delete
return config;
[34556] Fix | Delete
};
[34557] Fix | Delete
const getBlockSelectors = (blockTypes, getBlockStyles, variationInstanceId) => {
[34558] Fix | Delete
const result = {};
[34559] Fix | Delete
blockTypes.forEach(blockType => {
[34560] Fix | Delete
const name = blockType.name;
[34561] Fix | Delete
const selector = getBlockCSSSelector(blockType);
[34562] Fix | Delete
let duotoneSelector = getBlockCSSSelector(blockType, 'filter.duotone');
[34563] Fix | Delete
[34564] Fix | Delete
// Keep backwards compatibility for support.color.__experimentalDuotone.
[34565] Fix | Delete
if (!duotoneSelector) {
[34566] Fix | Delete
const rootSelector = getBlockCSSSelector(blockType);
[34567] Fix | Delete
const duotoneSupport = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, 'color.__experimentalDuotone', false);
[34568] Fix | Delete
duotoneSelector = duotoneSupport && scopeSelector(rootSelector, duotoneSupport);
[34569] Fix | Delete
}
[34570] Fix | Delete
const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout;
[34571] Fix | Delete
const fallbackGapValue = blockType?.supports?.spacing?.blockGap?.__experimentalDefault;
[34572] Fix | Delete
const blockStyleVariations = getBlockStyles(name);
[34573] Fix | Delete
const styleVariationSelectors = {};
[34574] Fix | Delete
blockStyleVariations?.forEach(variation => {
[34575] Fix | Delete
const variationSuffix = variationInstanceId ? `-${variationInstanceId}` : '';
[34576] Fix | Delete
const variationName = `${variation.name}${variationSuffix}`;
[34577] Fix | Delete
const styleVariationSelector = getBlockStyleVariationSelector(variationName, selector);
[34578] Fix | Delete
styleVariationSelectors[variationName] = styleVariationSelector;
[34579] Fix | Delete
});
[34580] Fix | Delete
[34581] Fix | Delete
// For each block support feature add any custom selectors.
[34582] Fix | Delete
const featureSelectors = getSelectorsConfig(blockType, selector);
[34583] Fix | Delete
result[name] = {
[34584] Fix | Delete
duotoneSelector,
[34585] Fix | Delete
fallbackGapValue,
[34586] Fix | Delete
featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : undefined,
[34587] Fix | Delete
hasLayoutSupport,
[34588] Fix | Delete
name,
[34589] Fix | Delete
selector,
[34590] Fix | Delete
styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : undefined
[34591] Fix | Delete
};
[34592] Fix | Delete
});
[34593] Fix | Delete
return result;
[34594] Fix | Delete
};
[34595] Fix | Delete
[34596] Fix | Delete
/**
[34597] Fix | Delete
* If there is a separator block whose color is defined in theme.json via background,
[34598] Fix | Delete
* update the separator color to the same value by using border color.
[34599] Fix | Delete
*
[34600] Fix | Delete
* @param {Object} config Theme.json configuration file object.
[34601] Fix | Delete
* @return {Object} configTheme.json configuration file object updated.
[34602] Fix | Delete
*/
[34603] Fix | Delete
function updateConfigWithSeparator(config) {
[34604] Fix | Delete
const needsSeparatorStyleUpdate = config.styles?.blocks?.['core/separator'] && config.styles?.blocks?.['core/separator'].color?.background && !config.styles?.blocks?.['core/separator'].color?.text && !config.styles?.blocks?.['core/separator'].border?.color;
[34605] Fix | Delete
if (needsSeparatorStyleUpdate) {
[34606] Fix | Delete
return {
[34607] Fix | Delete
...config,
[34608] Fix | Delete
styles: {
[34609] Fix | Delete
...config.styles,
[34610] Fix | Delete
blocks: {
[34611] Fix | Delete
...config.styles.blocks,
[34612] Fix | Delete
'core/separator': {
[34613] Fix | Delete
...config.styles.blocks['core/separator'],
[34614] Fix | Delete
color: {
[34615] Fix | Delete
...config.styles.blocks['core/separator'].color,
[34616] Fix | Delete
text: config.styles?.blocks['core/separator'].color.background
[34617] Fix | Delete
}
[34618] Fix | Delete
}
[34619] Fix | Delete
}
[34620] Fix | Delete
}
[34621] Fix | Delete
};
[34622] Fix | Delete
}
[34623] Fix | Delete
return config;
[34624] Fix | Delete
}
[34625] Fix | Delete
function processCSSNesting(css, blockSelector) {
[34626] Fix | Delete
let processedCSS = '';
[34627] Fix | Delete
if (!css || css.trim() === '') {
[34628] Fix | Delete
return processedCSS;
[34629] Fix | Delete
}
[34630] Fix | Delete
[34631] Fix | Delete
// Split CSS nested rules.
[34632] Fix | Delete
const parts = css.split('&');
[34633] Fix | Delete
parts.forEach(part => {
[34634] Fix | Delete
if (!part || part.trim() === '') {
[34635] Fix | Delete
return;
[34636] Fix | Delete
}
[34637] Fix | Delete
const isRootCss = !part.includes('{');
[34638] Fix | Delete
if (isRootCss) {
[34639] Fix | Delete
// If the part doesn't contain braces, it applies to the root level.
[34640] Fix | Delete
processedCSS += `:root :where(${blockSelector}){${part.trim()}}`;
[34641] Fix | Delete
} else {
[34642] Fix | Delete
// If the part contains braces, it's a nested CSS rule.
[34643] Fix | Delete
const splittedPart = part.replace('}', '').split('{');
[34644] Fix | Delete
if (splittedPart.length !== 2) {
[34645] Fix | Delete
return;
[34646] Fix | Delete
}
[34647] Fix | Delete
const [nestedSelector, cssValue] = splittedPart;
[34648] Fix | Delete
[34649] Fix | Delete
// Handle pseudo elements such as ::before, ::after, etc. Regex will also
[34650] Fix | Delete
// capture any leading combinator such as >, +, or ~, as well as spaces.
[34651] Fix | Delete
// This allows pseudo elements as descendants e.g. `.parent ::before`.
[34652] Fix | Delete
const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/);
[34653] Fix | Delete
const pseudoPart = matches ? matches[1] : '';
[34654] Fix | Delete
const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, '').trim() : nestedSelector.trim();
[34655] Fix | Delete
let combinedSelector;
[34656] Fix | Delete
if (withoutPseudoElement === '') {
[34657] Fix | Delete
// Only contained a pseudo element to use the block selector to form
[34658] Fix | Delete
// the final `:root :where()` selector.
[34659] Fix | Delete
combinedSelector = blockSelector;
[34660] Fix | Delete
} else {
[34661] Fix | Delete
// If the nested selector is a descendant of the block scope it with the
[34662] Fix | Delete
// block selector. Otherwise append it to the block selector.
[34663] Fix | Delete
combinedSelector = nestedSelector.startsWith(' ') ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement);
[34664] Fix | Delete
}
[34665] Fix | Delete
[34666] Fix | Delete
// Build final rule, re-adding any pseudo element outside the `:where()`
[34667] Fix | Delete
// to maintain valid CSS selector.
[34668] Fix | Delete
processedCSS += `:root :where(${combinedSelector})${pseudoPart}{${cssValue.trim()}}`;
[34669] Fix | Delete
}
[34670] Fix | Delete
});
[34671] Fix | Delete
return processedCSS;
[34672] Fix | Delete
}
[34673] Fix | Delete
[34674] Fix | Delete
/**
[34675] Fix | Delete
* Returns the global styles output using a global styles configuration.
[34676] Fix | Delete
* If wishing to generate global styles and settings based on the
[34677] Fix | Delete
* global styles config loaded in the editor context, use `useGlobalStylesOutput()`.
[34678] Fix | Delete
* The use case for a custom config is to generate bespoke styles
[34679] Fix | Delete
* and settings for previews, or other out-of-editor experiences.
[34680] Fix | Delete
*
[34681] Fix | Delete
* @param {Object} mergedConfig Global styles configuration.
[34682] Fix | Delete
* @param {boolean} disableRootPadding Disable root padding styles.
[34683] Fix | Delete
*
[34684] Fix | Delete
* @return {Array} Array of stylesheets and settings.
[34685] Fix | Delete
*/
[34686] Fix | Delete
function useGlobalStylesOutputWithConfig(mergedConfig = {}, disableRootPadding) {
[34687] Fix | Delete
const [blockGap] = useGlobalSetting('spacing.blockGap');
[34688] Fix | Delete
mergedConfig = setThemeFileUris(mergedConfig, mergedConfig?._links?.['wp:theme-file']);
[34689] Fix | Delete
const hasBlockGapSupport = blockGap !== null;
[34690] Fix | Delete
const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
[34691] Fix | Delete
const disableLayoutStyles = (0,external_wp_data_namespaceObject.useSelect)(select => {
[34692] Fix | Delete
const {
[34693] Fix | Delete
getSettings
[34694] Fix | Delete
} = select(store);
[34695] Fix | Delete
return !!getSettings().disableLayoutStyles;
[34696] Fix | Delete
});
[34697] Fix | Delete
const {
[34698] Fix | Delete
getBlockStyles
[34699] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
[34700] Fix | Delete
return (0,external_wp_element_namespaceObject.useMemo)(() => {
[34701] Fix | Delete
var _updatedConfig$styles;
[34702] Fix | Delete
if (!mergedConfig?.styles || !mergedConfig?.settings) {
[34703] Fix | Delete
return [];
[34704] Fix | Delete
}
[34705] Fix | Delete
const updatedConfig = updateConfigWithSeparator(mergedConfig);
[34706] Fix | Delete
const blockSelectors = getBlockSelectors((0,external_wp_blocks_namespaceObject.getBlockTypes)(), getBlockStyles);
[34707] Fix | Delete
const customProperties = toCustomProperties(updatedConfig, blockSelectors);
[34708] Fix | Delete
const globalStyles = toStyles(updatedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles, disableRootPadding);
[34709] Fix | Delete
const svgs = toSvgFilters(updatedConfig, blockSelectors);
[34710] Fix | Delete
const styles = [{
[34711] Fix | Delete
css: customProperties,
[34712] Fix | Delete
isGlobalStyles: true
[34713] Fix | Delete
}, {
[34714] Fix | Delete
css: globalStyles,
[34715] Fix | Delete
isGlobalStyles: true
[34716] Fix | Delete
},
[34717] Fix | Delete
// Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
[34718] Fix | Delete
{
[34719] Fix | Delete
css: (_updatedConfig$styles = updatedConfig.styles.css) !== null && _updatedConfig$styles !== void 0 ? _updatedConfig$styles : '',
[34720] Fix | Delete
isGlobalStyles: true
[34721] Fix | Delete
}, {
[34722] Fix | Delete
assets: svgs,
[34723] Fix | Delete
__unstableType: 'svg',
[34724] Fix | Delete
isGlobalStyles: true
[34725] Fix | Delete
}];
[34726] Fix | Delete
[34727] Fix | Delete
// Loop through the blocks to check if there are custom CSS values.
[34728] Fix | Delete
// If there are, get the block selector and push the selector together with
[34729] Fix | Delete
// the CSS value to the 'stylesheets' array.
[34730] Fix | Delete
(0,external_wp_blocks_namespaceObject.getBlockTypes)().forEach(blockType => {
[34731] Fix | Delete
if (updatedConfig.styles.blocks[blockType.name]?.css) {
[34732] Fix | Delete
const selector = blockSelectors[blockType.name].selector;
[34733] Fix | Delete
styles.push({
[34734] Fix | Delete
css: processCSSNesting(updatedConfig.styles.blocks[blockType.name]?.css, selector),
[34735] Fix | Delete
isGlobalStyles: true
[34736] Fix | Delete
});
[34737] Fix | Delete
}
[34738] Fix | Delete
});
[34739] Fix | Delete
return [styles, updatedConfig.settings];
[34740] Fix | Delete
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles, disableRootPadding, getBlockStyles]);
[34741] Fix | Delete
}
[34742] Fix | Delete
[34743] Fix | Delete
/**
[34744] Fix | Delete
* Returns the global styles output based on the current state of global styles config loaded in the editor context.
[34745] Fix | Delete
*
[34746] Fix | Delete
* @param {boolean} disableRootPadding Disable root padding styles.
[34747] Fix | Delete
*
[34748] Fix | Delete
* @return {Array} Array of stylesheets and settings.
[34749] Fix | Delete
*/
[34750] Fix | Delete
function useGlobalStylesOutput(disableRootPadding = false) {
[34751] Fix | Delete
const {
[34752] Fix | Delete
merged: mergedConfig
[34753] Fix | Delete
} = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
[34754] Fix | Delete
return useGlobalStylesOutputWithConfig(mergedConfig, disableRootPadding);
[34755] Fix | Delete
}
[34756] Fix | Delete
[34757] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/block-style-variation.js
[34758] Fix | Delete
/**
[34759] Fix | Delete
* WordPress dependencies
[34760] Fix | Delete
*/
[34761] Fix | Delete
[34762] Fix | Delete
[34763] Fix | Delete
[34764] Fix | Delete
[34765] Fix | Delete
/**
[34766] Fix | Delete
* Internal dependencies
[34767] Fix | Delete
*/
[34768] Fix | Delete
[34769] Fix | Delete
[34770] Fix | Delete
[34771] Fix | Delete
[34772] Fix | Delete
[34773] Fix | Delete
[34774] Fix | Delete
[34775] Fix | Delete
[34776] Fix | Delete
const VARIATION_PREFIX = 'is-style-';
[34777] Fix | Delete
function getVariationMatches(className) {
[34778] Fix | Delete
if (!className) {
[34779] Fix | Delete
return [];
[34780] Fix | Delete
}
[34781] Fix | Delete
return className.split(/\s+/).reduce((matches, name) => {
[34782] Fix | Delete
if (name.startsWith(VARIATION_PREFIX)) {
[34783] Fix | Delete
const match = name.slice(VARIATION_PREFIX.length);
[34784] Fix | Delete
if (match !== 'default') {
[34785] Fix | Delete
matches.push(match);
[34786] Fix | Delete
}
[34787] Fix | Delete
}
[34788] Fix | Delete
return matches;
[34789] Fix | Delete
}, []);
[34790] Fix | Delete
}
[34791] Fix | Delete
[34792] Fix | Delete
/**
[34793] Fix | Delete
* Get the first block style variation that has been registered from the class string.
[34794] Fix | Delete
*
[34795] Fix | Delete
* @param {string} className CSS class string for a block.
[34796] Fix | Delete
* @param {Array} registeredStyles Currently registered block styles.
[34797] Fix | Delete
*
[34798] Fix | Delete
* @return {string|null} The name of the first registered variation.
[34799] Fix | Delete
*/
[34800] Fix | Delete
function getVariationNameFromClass(className, registeredStyles = []) {
[34801] Fix | Delete
// The global flag affects how capturing groups work in JS. So the regex
[34802] Fix | Delete
// below will only return full CSS classes not just the variation name.
[34803] Fix | Delete
const matches = getVariationMatches(className);
[34804] Fix | Delete
if (!matches) {
[34805] Fix | Delete
return null;
[34806] Fix | Delete
}
[34807] Fix | Delete
for (const variation of matches) {
[34808] Fix | Delete
if (registeredStyles.some(style => style.name === variation)) {
[34809] Fix | Delete
return variation;
[34810] Fix | Delete
}
[34811] Fix | Delete
}
[34812] Fix | Delete
return null;
[34813] Fix | Delete
}
[34814] Fix | Delete
[34815] Fix | Delete
// A helper component to apply a style override using the useStyleOverride hook.
[34816] Fix | Delete
function OverrideStyles({
[34817] Fix | Delete
override
[34818] Fix | Delete
}) {
[34819] Fix | Delete
useStyleOverride(override);
[34820] Fix | Delete
}
[34821] Fix | Delete
[34822] Fix | Delete
/**
[34823] Fix | Delete
* This component is used to generate new block style variation overrides
[34824] Fix | Delete
* based on an incoming theme config. If a matching style is found in the config,
[34825] Fix | Delete
* a new override is created and returned. The overrides can be used in conjunction with
[34826] Fix | Delete
* useStyleOverride to apply the new styles to the editor. Its use is
[34827] Fix | Delete
* subject to change.
[34828] Fix | Delete
*
[34829] Fix | Delete
* @param {Object} props Props.
[34830] Fix | Delete
* @param {Object} props.config A global styles object, containing settings and styles.
[34831] Fix | Delete
* @return {JSX.Element|undefined} An array of new block variation overrides.
[34832] Fix | Delete
*/
[34833] Fix | Delete
function __unstableBlockStyleVariationOverridesWithConfig({
[34834] Fix | Delete
config
[34835] Fix | Delete
}) {
[34836] Fix | Delete
const {
[34837] Fix | Delete
getBlockStyles,
[34838] Fix | Delete
overrides
[34839] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => ({
[34840] Fix | Delete
getBlockStyles: select(external_wp_blocks_namespaceObject.store).getBlockStyles,
[34841] Fix | Delete
overrides: unlock(select(store)).getStyleOverrides()
[34842] Fix | Delete
}), []);
[34843] Fix | Delete
const {
[34844] Fix | Delete
getBlockName
[34845] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store);
[34846] Fix | Delete
const overridesWithConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
[34847] Fix | Delete
if (!overrides?.length) {
[34848] Fix | Delete
return;
[34849] Fix | Delete
}
[34850] Fix | Delete
const newOverrides = [];
[34851] Fix | Delete
const overriddenClientIds = [];
[34852] Fix | Delete
for (const [, override] of overrides) {
[34853] Fix | Delete
if (override?.variation && override?.clientId &&
[34854] Fix | Delete
/*
[34855] Fix | Delete
* Because this component overwrites existing style overrides,
[34856] Fix | Delete
* filter out any overrides that are already present in the store.
[34857] Fix | Delete
*/
[34858] Fix | Delete
!overriddenClientIds.includes(override.clientId)) {
[34859] Fix | Delete
const blockName = getBlockName(override.clientId);
[34860] Fix | Delete
const configStyles = config?.styles?.blocks?.[blockName]?.variations?.[override.variation];
[34861] Fix | Delete
if (configStyles) {
[34862] Fix | Delete
const variationConfig = {
[34863] Fix | Delete
settings: config?.settings,
[34864] Fix | Delete
// The variation style data is all that is needed to generate
[34865] Fix | Delete
// the styles for the current application to a block. The variation
[34866] Fix | Delete
// name is updated to match the instance specific class name.
[34867] Fix | Delete
styles: {
[34868] Fix | Delete
blocks: {
[34869] Fix | Delete
[blockName]: {
[34870] Fix | Delete
variations: {
[34871] Fix | Delete
[`${override.variation}-${override.clientId}`]: configStyles
[34872] Fix | Delete
}
[34873] Fix | Delete
}
[34874] Fix | Delete
}
[34875] Fix | Delete
}
[34876] Fix | Delete
};
[34877] Fix | Delete
const blockSelectors = getBlockSelectors((0,external_wp_blocks_namespaceObject.getBlockTypes)(), getBlockStyles, override.clientId);
[34878] Fix | Delete
const hasBlockGapSupport = false;
[34879] Fix | Delete
const hasFallbackGapSupport = true;
[34880] Fix | Delete
const disableLayoutStyles = true;
[34881] Fix | Delete
const disableRootPadding = true;
[34882] Fix | Delete
const variationStyles = toStyles(variationConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles, disableRootPadding, {
[34883] Fix | Delete
blockGap: false,
[34884] Fix | Delete
blockStyles: true,
[34885] Fix | Delete
layoutStyles: false,
[34886] Fix | Delete
marginReset: false,
[34887] Fix | Delete
presets: false,
[34888] Fix | Delete
rootPadding: false,
[34889] Fix | Delete
variationStyles: true
[34890] Fix | Delete
});
[34891] Fix | Delete
newOverrides.push({
[34892] Fix | Delete
id: `${override.variation}-${override.clientId}`,
[34893] Fix | Delete
css: variationStyles,
[34894] Fix | Delete
__unstableType: 'variation',
[34895] Fix | Delete
variation: override.variation,
[34896] Fix | Delete
// The clientId will be stored with the override and used to ensure
[34897] Fix | Delete
// the order of overrides matches the order of blocks so that the
[34898] Fix | Delete
// correct CSS cascade is maintained.
[34899] Fix | Delete
clientId: override.clientId
[34900] Fix | Delete
});
[34901] Fix | Delete
overriddenClientIds.push(override.clientId);
[34902] Fix | Delete
}
[34903] Fix | Delete
}
[34904] Fix | Delete
}
[34905] Fix | Delete
return newOverrides;
[34906] Fix | Delete
}, [config, overrides, getBlockStyles, getBlockName]);
[34907] Fix | Delete
if (!overridesWithConfig || !overridesWithConfig.length) {
[34908] Fix | Delete
return;
[34909] Fix | Delete
}
[34910] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[34911] Fix | Delete
children: overridesWithConfig.map(override => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OverrideStyles, {
[34912] Fix | Delete
override: override
[34913] Fix | Delete
}, override.id))
[34914] Fix | Delete
});
[34915] Fix | Delete
}
[34916] Fix | Delete
[34917] Fix | Delete
/**
[34918] Fix | Delete
* Retrieves any variation styles data and resolves any referenced values.
[34919] Fix | Delete
*
[34920] Fix | Delete
* @param {Object} globalStyles A complete global styles object, containing settings and styles.
[34921] Fix | Delete
* @param {string} name The name of the desired block type.
[34922] Fix | Delete
* @param {variation} variation The of the block style variation to retrieve data for.
[34923] Fix | Delete
*
[34924] Fix | Delete
* @return {Object|undefined} The global styles data for the specified variation.
[34925] Fix | Delete
*/
[34926] Fix | Delete
function getVariationStylesWithRefValues(globalStyles, name, variation) {
[34927] Fix | Delete
if (!globalStyles?.styles?.blocks?.[name]?.variations?.[variation]) {
[34928] Fix | Delete
return;
[34929] Fix | Delete
}
[34930] Fix | Delete
[34931] Fix | Delete
// Helper to recursively look for `ref` values to resolve.
[34932] Fix | Delete
const replaceRefs = variationStyles => {
[34933] Fix | Delete
Object.keys(variationStyles).forEach(key => {
[34934] Fix | Delete
const value = variationStyles[key];
[34935] Fix | Delete
[34936] Fix | Delete
// Only process objects.
[34937] Fix | Delete
if (typeof value === 'object' && value !== null) {
[34938] Fix | Delete
// Process `ref` value if present.
[34939] Fix | Delete
if (value.ref !== undefined) {
[34940] Fix | Delete
if (typeof value.ref !== 'string' || value.ref.trim() === '') {
[34941] Fix | Delete
// Remove invalid ref.
[34942] Fix | Delete
delete variationStyles[key];
[34943] Fix | Delete
} else {
[34944] Fix | Delete
// Resolve `ref` value.
[34945] Fix | Delete
const refValue = getValueFromObjectPath(globalStyles, value.ref);
[34946] Fix | Delete
if (refValue) {
[34947] Fix | Delete
variationStyles[key] = refValue;
[34948] Fix | Delete
} else {
[34949] Fix | Delete
delete variationStyles[key];
[34950] Fix | Delete
}
[34951] Fix | Delete
}
[34952] Fix | Delete
} else {
[34953] Fix | Delete
// Recursively resolve `ref` values in nested objects.
[34954] Fix | Delete
replaceRefs(value);
[34955] Fix | Delete
[34956] Fix | Delete
// After recursion, if value is empty due to explicitly
[34957] Fix | Delete
// `undefined` ref value, remove it.
[34958] Fix | Delete
if (Object.keys(value).length === 0) {
[34959] Fix | Delete
delete variationStyles[key];
[34960] Fix | Delete
}
[34961] Fix | Delete
}
[34962] Fix | Delete
}
[34963] Fix | Delete
});
[34964] Fix | Delete
};
[34965] Fix | Delete
[34966] Fix | Delete
// Deep clone variation node to avoid mutating it within global styles and losing refs.
[34967] Fix | Delete
const styles = JSON.parse(JSON.stringify(globalStyles.styles.blocks[name].variations[variation]));
[34968] Fix | Delete
replaceRefs(styles);
[34969] Fix | Delete
return styles;
[34970] Fix | Delete
}
[34971] Fix | Delete
function useBlockStyleVariation(name, variation, clientId) {
[34972] Fix | Delete
// Prefer global styles data in GlobalStylesContext, which are available
[34973] Fix | Delete
// if in the site editor. Otherwise fall back to whatever is in the
[34974] Fix | Delete
// editor settings and available in the post editor.
[34975] Fix | Delete
const {
[34976] Fix | Delete
merged: mergedConfig
[34977] Fix | Delete
} = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
[34978] Fix | Delete
const {
[34979] Fix | Delete
globalSettings,
[34980] Fix | Delete
globalStyles
[34981] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[34982] Fix | Delete
const settings = select(store).getSettings();
[34983] Fix | Delete
return {
[34984] Fix | Delete
globalSettings: settings.__experimentalFeatures,
[34985] Fix | Delete
globalStyles: settings[globalStylesDataKey]
[34986] Fix | Delete
};
[34987] Fix | Delete
}, []);
[34988] Fix | Delete
return (0,external_wp_element_namespaceObject.useMemo)(() => {
[34989] Fix | Delete
var _mergedConfig$setting, _mergedConfig$styles, _mergedConfig$setting2;
[34990] Fix | Delete
const variationStyles = getVariationStylesWithRefValues({
[34991] Fix | Delete
settings: (_mergedConfig$setting = mergedConfig?.settings) !== null && _mergedConfig$setting !== void 0 ? _mergedConfig$setting : globalSettings,
[34992] Fix | Delete
styles: (_mergedConfig$styles = mergedConfig?.styles) !== null && _mergedConfig$styles !== void 0 ? _mergedConfig$styles : globalStyles
[34993] Fix | Delete
}, name, variation);
[34994] Fix | Delete
return {
[34995] Fix | Delete
settings: (_mergedConfig$setting2 = mergedConfig?.settings) !== null && _mergedConfig$setting2 !== void 0 ? _mergedConfig$setting2 : globalSettings,
[34996] Fix | Delete
// The variation style data is all that is needed to generate
[34997] Fix | Delete
// the styles for the current application to a block. The variation
[34998] Fix | Delete
// name is updated to match the instance specific class name.
[34999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function