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
* @param {string|Object} blockType Block name or Block Type object.
[33500] Fix | Delete
*
[33501] Fix | Delete
* @return {boolean} Whether there is support.
[33502] Fix | Delete
*/
[33503] Fix | Delete
function hasPositionSupport(blockType) {
[33504] Fix | Delete
const support = (0,external_wp_blocks_namespaceObject.getBlockSupport)(blockType, POSITION_SUPPORT_KEY);
[33505] Fix | Delete
return !!support;
[33506] Fix | Delete
}
[33507] Fix | Delete
[33508] Fix | Delete
/**
[33509] Fix | Delete
* Checks if there is a current value in the position block support attributes.
[33510] Fix | Delete
*
[33511] Fix | Delete
* @param {Object} props Block props.
[33512] Fix | Delete
* @return {boolean} Whether or not the block has a position value set.
[33513] Fix | Delete
*/
[33514] Fix | Delete
function hasPositionValue(props) {
[33515] Fix | Delete
return props.attributes.style?.position?.type !== undefined;
[33516] Fix | Delete
}
[33517] Fix | Delete
[33518] Fix | Delete
/**
[33519] Fix | Delete
* Checks if the block is currently set to a sticky or fixed position.
[33520] Fix | Delete
* This check is helpful for determining how to position block toolbars or other elements.
[33521] Fix | Delete
*
[33522] Fix | Delete
* @param {Object} attributes Block attributes.
[33523] Fix | Delete
* @return {boolean} Whether or not the block is set to a sticky or fixed position.
[33524] Fix | Delete
*/
[33525] Fix | Delete
function hasStickyOrFixedPositionValue(attributes) {
[33526] Fix | Delete
const positionType = attributes?.style?.position?.type;
[33527] Fix | Delete
return positionType === 'sticky' || positionType === 'fixed';
[33528] Fix | Delete
}
[33529] Fix | Delete
[33530] Fix | Delete
/**
[33531] Fix | Delete
* Resets the position block support attributes. This can be used when disabling
[33532] Fix | Delete
* the position support controls for a block via a `ToolsPanel`.
[33533] Fix | Delete
*
[33534] Fix | Delete
* @param {Object} props Block props.
[33535] Fix | Delete
* @param {Object} props.attributes Block's attributes.
[33536] Fix | Delete
* @param {Object} props.setAttributes Function to set block's attributes.
[33537] Fix | Delete
*/
[33538] Fix | Delete
function resetPosition({
[33539] Fix | Delete
attributes = {},
[33540] Fix | Delete
setAttributes
[33541] Fix | Delete
}) {
[33542] Fix | Delete
const {
[33543] Fix | Delete
style = {}
[33544] Fix | Delete
} = attributes;
[33545] Fix | Delete
setAttributes({
[33546] Fix | Delete
style: cleanEmptyObject({
[33547] Fix | Delete
...style,
[33548] Fix | Delete
position: {
[33549] Fix | Delete
...style?.position,
[33550] Fix | Delete
type: undefined,
[33551] Fix | Delete
top: undefined,
[33552] Fix | Delete
right: undefined,
[33553] Fix | Delete
bottom: undefined,
[33554] Fix | Delete
left: undefined
[33555] Fix | Delete
}
[33556] Fix | Delete
})
[33557] Fix | Delete
});
[33558] Fix | Delete
}
[33559] Fix | Delete
[33560] Fix | Delete
/**
[33561] Fix | Delete
* Custom hook that checks if position settings have been disabled.
[33562] Fix | Delete
*
[33563] Fix | Delete
* @param {string} name The name of the block.
[33564] Fix | Delete
*
[33565] Fix | Delete
* @return {boolean} Whether padding setting is disabled.
[33566] Fix | Delete
*/
[33567] Fix | Delete
function useIsPositionDisabled({
[33568] Fix | Delete
name: blockName
[33569] Fix | Delete
} = {}) {
[33570] Fix | Delete
const [allowFixed, allowSticky] = use_settings_useSettings('position.fixed', 'position.sticky');
[33571] Fix | Delete
const isDisabled = !allowFixed && !allowSticky;
[33572] Fix | Delete
return !hasPositionSupport(blockName) || isDisabled;
[33573] Fix | Delete
}
[33574] Fix | Delete
[33575] Fix | Delete
/*
[33576] Fix | Delete
* Position controls rendered in an inspector control panel.
[33577] Fix | Delete
*
[33578] Fix | Delete
* @param {Object} props
[33579] Fix | Delete
*
[33580] Fix | Delete
* @return {Element} Position panel.
[33581] Fix | Delete
*/
[33582] Fix | Delete
function PositionPanelPure({
[33583] Fix | Delete
style = {},
[33584] Fix | Delete
clientId,
[33585] Fix | Delete
name: blockName,
[33586] Fix | Delete
setAttributes
[33587] Fix | Delete
}) {
[33588] Fix | Delete
const allowFixed = hasFixedPositionSupport(blockName);
[33589] Fix | Delete
const allowSticky = hasStickyPositionSupport(blockName);
[33590] Fix | Delete
const value = style?.position?.type;
[33591] Fix | Delete
const {
[33592] Fix | Delete
firstParentClientId
[33593] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[33594] Fix | Delete
const {
[33595] Fix | Delete
getBlockParents
[33596] Fix | Delete
} = select(store);
[33597] Fix | Delete
const parents = getBlockParents(clientId);
[33598] Fix | Delete
return {
[33599] Fix | Delete
firstParentClientId: parents[parents.length - 1]
[33600] Fix | Delete
};
[33601] Fix | Delete
}, [clientId]);
[33602] Fix | Delete
const blockInformation = useBlockDisplayInformation(firstParentClientId);
[33603] Fix | Delete
const stickyHelpText = allowSticky && value === STICKY_OPTION.value && blockInformation ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: the name of the parent block. */
[33604] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('The block will stick to the scrollable area of the parent %s block.'), blockInformation.title) : null;
[33605] Fix | Delete
const options = (0,external_wp_element_namespaceObject.useMemo)(() => {
[33606] Fix | Delete
const availableOptions = [DEFAULT_OPTION];
[33607] Fix | Delete
// Display options if they are allowed, or if a block already has a valid value set.
[33608] Fix | Delete
// This allows for a block to be switched off from a position type that is not allowed.
[33609] Fix | Delete
if (allowSticky || value === STICKY_OPTION.value) {
[33610] Fix | Delete
availableOptions.push(STICKY_OPTION);
[33611] Fix | Delete
}
[33612] Fix | Delete
if (allowFixed || value === FIXED_OPTION.value) {
[33613] Fix | Delete
availableOptions.push(FIXED_OPTION);
[33614] Fix | Delete
}
[33615] Fix | Delete
return availableOptions;
[33616] Fix | Delete
}, [allowFixed, allowSticky, value]);
[33617] Fix | Delete
const onChangeType = next => {
[33618] Fix | Delete
// For now, use a hard-coded `0px` value for the position.
[33619] Fix | Delete
// `0px` is preferred over `0` as it can be used in `calc()` functions.
[33620] Fix | Delete
// In the future, it could be useful to allow for an offset value.
[33621] Fix | Delete
const placementValue = '0px';
[33622] Fix | Delete
const newStyle = {
[33623] Fix | Delete
...style,
[33624] Fix | Delete
position: {
[33625] Fix | Delete
...style?.position,
[33626] Fix | Delete
type: next,
[33627] Fix | Delete
top: next === 'sticky' || next === 'fixed' ? placementValue : undefined
[33628] Fix | Delete
}
[33629] Fix | Delete
};
[33630] Fix | Delete
setAttributes({
[33631] Fix | Delete
style: utils_cleanEmptyObject(newStyle)
[33632] Fix | Delete
});
[33633] Fix | Delete
};
[33634] Fix | Delete
const selectedOption = value ? options.find(option => option.value === value) || DEFAULT_OPTION : DEFAULT_OPTION;
[33635] Fix | Delete
[33636] Fix | Delete
// Only display position controls if there is at least one option to choose from.
[33637] Fix | Delete
return external_wp_element_namespaceObject.Platform.select({
[33638] Fix | Delete
web: options.length > 1 ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls, {
[33639] Fix | Delete
group: "position",
[33640] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, {
[33641] Fix | Delete
className: "block-editor-hooks__position-selection",
[33642] Fix | Delete
__nextHasNoMarginBottom: true,
[33643] Fix | Delete
help: stickyHelpText,
[33644] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CustomSelectControl, {
[33645] Fix | Delete
__next40pxDefaultSize: true,
[33646] Fix | Delete
className: "block-editor-hooks__position-selection__select-control",
[33647] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Position'),
[33648] Fix | Delete
hideLabelFromVision: true,
[33649] Fix | Delete
describedBy: (0,external_wp_i18n_namespaceObject.sprintf)(
[33650] Fix | Delete
// translators: %s: Currently selected position.
[33651] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('Currently selected position: %s'), selectedOption.name),
[33652] Fix | Delete
options: options,
[33653] Fix | Delete
value: selectedOption,
[33654] Fix | Delete
__experimentalShowSelectedHint: true,
[33655] Fix | Delete
onChange: ({
[33656] Fix | Delete
selectedItem
[33657] Fix | Delete
}) => {
[33658] Fix | Delete
onChangeType(selectedItem.value);
[33659] Fix | Delete
},
[33660] Fix | Delete
size: "__unstable-large"
[33661] Fix | Delete
})
[33662] Fix | Delete
})
[33663] Fix | Delete
}) : null,
[33664] Fix | Delete
native: null
[33665] Fix | Delete
});
[33666] Fix | Delete
}
[33667] Fix | Delete
/* harmony default export */ const position = ({
[33668] Fix | Delete
edit: function Edit(props) {
[33669] Fix | Delete
const isPositionDisabled = useIsPositionDisabled(props);
[33670] Fix | Delete
if (isPositionDisabled) {
[33671] Fix | Delete
return null;
[33672] Fix | Delete
}
[33673] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PositionPanelPure, {
[33674] Fix | Delete
...props
[33675] Fix | Delete
});
[33676] Fix | Delete
},
[33677] Fix | Delete
useBlockProps: position_useBlockProps,
[33678] Fix | Delete
attributeKeys: ['style'],
[33679] Fix | Delete
hasSupport(name) {
[33680] Fix | Delete
return (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, POSITION_SUPPORT_KEY);
[33681] Fix | Delete
}
[33682] Fix | Delete
});
[33683] Fix | Delete
function position_useBlockProps({
[33684] Fix | Delete
name,
[33685] Fix | Delete
style
[33686] Fix | Delete
}) {
[33687] Fix | Delete
const hasPositionBlockSupport = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(name, POSITION_SUPPORT_KEY);
[33688] Fix | Delete
const isPositionDisabled = useIsPositionDisabled({
[33689] Fix | Delete
name
[33690] Fix | Delete
});
[33691] Fix | Delete
const allowPositionStyles = hasPositionBlockSupport && !isPositionDisabled;
[33692] Fix | Delete
const id = (0,external_wp_compose_namespaceObject.useInstanceId)(position_useBlockProps);
[33693] Fix | Delete
[33694] Fix | Delete
// Higher specificity to override defaults in editor UI.
[33695] Fix | Delete
const positionSelector = `.wp-container-${id}.wp-container-${id}`;
[33696] Fix | Delete
[33697] Fix | Delete
// Get CSS string for the current position values.
[33698] Fix | Delete
let css;
[33699] Fix | Delete
if (allowPositionStyles) {
[33700] Fix | Delete
css = getPositionCSS({
[33701] Fix | Delete
selector: positionSelector,
[33702] Fix | Delete
style
[33703] Fix | Delete
}) || '';
[33704] Fix | Delete
}
[33705] Fix | Delete
[33706] Fix | Delete
// Attach a `wp-container-` id-based class name.
[33707] Fix | Delete
const className = dist_clsx({
[33708] Fix | Delete
[`wp-container-${id}`]: allowPositionStyles && !!css,
[33709] Fix | Delete
// Only attach a container class if there is generated CSS to be attached.
[33710] Fix | Delete
[`is-position-${style?.position?.type}`]: allowPositionStyles && !!css && !!style?.position?.type
[33711] Fix | Delete
});
[33712] Fix | Delete
useStyleOverride({
[33713] Fix | Delete
css
[33714] Fix | Delete
});
[33715] Fix | Delete
return {
[33716] Fix | Delete
className
[33717] Fix | Delete
};
[33718] Fix | Delete
}
[33719] Fix | Delete
[33720] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/global-styles/use-global-styles-output.js
[33721] Fix | Delete
/**
[33722] Fix | Delete
* WordPress dependencies
[33723] Fix | Delete
*/
[33724] Fix | Delete
[33725] Fix | Delete
[33726] Fix | Delete
[33727] Fix | Delete
[33728] Fix | Delete
[33729] Fix | Delete
[33730] Fix | Delete
/**
[33731] Fix | Delete
* Internal dependencies
[33732] Fix | Delete
*/
[33733] Fix | Delete
[33734] Fix | Delete
[33735] Fix | Delete
[33736] Fix | Delete
[33737] Fix | Delete
[33738] Fix | Delete
[33739] Fix | Delete
[33740] Fix | Delete
[33741] Fix | Delete
[33742] Fix | Delete
[33743] Fix | Delete
[33744] Fix | Delete
[33745] Fix | Delete
[33746] Fix | Delete
// Elements that rely on class names in their selectors.
[33747] Fix | Delete
const ELEMENT_CLASS_NAMES = {
[33748] Fix | Delete
button: 'wp-element-button',
[33749] Fix | Delete
caption: 'wp-element-caption'
[33750] Fix | Delete
};
[33751] Fix | Delete
[33752] Fix | Delete
// List of block support features that can have their related styles
[33753] Fix | Delete
// generated under their own feature level selector rather than the block's.
[33754] Fix | Delete
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
[33755] Fix | Delete
__experimentalBorder: 'border',
[33756] Fix | Delete
color: 'color',
[33757] Fix | Delete
spacing: 'spacing',
[33758] Fix | Delete
typography: 'typography'
[33759] Fix | Delete
};
[33760] Fix | Delete
const {
[33761] Fix | Delete
kebabCase: use_global_styles_output_kebabCase
[33762] Fix | Delete
} = unlock(external_wp_components_namespaceObject.privateApis);
[33763] Fix | Delete
function compileStyleValue(uncompiledValue) {
[33764] Fix | Delete
const VARIABLE_REFERENCE_PREFIX = 'var:';
[33765] Fix | Delete
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
[33766] Fix | Delete
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
[33767] Fix | Delete
if (uncompiledValue?.startsWith?.(VARIABLE_REFERENCE_PREFIX)) {
[33768] Fix | Delete
const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
[33769] Fix | Delete
return `var(--wp--${variable})`;
[33770] Fix | Delete
}
[33771] Fix | Delete
return uncompiledValue;
[33772] Fix | Delete
}
[33773] Fix | Delete
[33774] Fix | Delete
/**
[33775] Fix | Delete
* Transform given preset tree into a set of style declarations.
[33776] Fix | Delete
*
[33777] Fix | Delete
* @param {Object} blockPresets
[33778] Fix | Delete
* @param {Object} mergedSettings Merged theme.json settings.
[33779] Fix | Delete
*
[33780] Fix | Delete
* @return {Array<Object>} An array of style declarations.
[33781] Fix | Delete
*/
[33782] Fix | Delete
function getPresetsDeclarations(blockPresets = {}, mergedSettings) {
[33783] Fix | Delete
return PRESET_METADATA.reduce((declarations, {
[33784] Fix | Delete
path,
[33785] Fix | Delete
valueKey,
[33786] Fix | Delete
valueFunc,
[33787] Fix | Delete
cssVarInfix
[33788] Fix | Delete
}) => {
[33789] Fix | Delete
const presetByOrigin = getValueFromObjectPath(blockPresets, path, []);
[33790] Fix | Delete
['default', 'theme', 'custom'].forEach(origin => {
[33791] Fix | Delete
if (presetByOrigin[origin]) {
[33792] Fix | Delete
presetByOrigin[origin].forEach(value => {
[33793] Fix | Delete
if (valueKey && !valueFunc) {
[33794] Fix | Delete
declarations.push(`--wp--preset--${cssVarInfix}--${use_global_styles_output_kebabCase(value.slug)}: ${value[valueKey]}`);
[33795] Fix | Delete
} else if (valueFunc && typeof valueFunc === 'function') {
[33796] Fix | Delete
declarations.push(`--wp--preset--${cssVarInfix}--${use_global_styles_output_kebabCase(value.slug)}: ${valueFunc(value, mergedSettings)}`);
[33797] Fix | Delete
}
[33798] Fix | Delete
});
[33799] Fix | Delete
}
[33800] Fix | Delete
});
[33801] Fix | Delete
return declarations;
[33802] Fix | Delete
}, []);
[33803] Fix | Delete
}
[33804] Fix | Delete
[33805] Fix | Delete
/**
[33806] Fix | Delete
* Transform given preset tree into a set of preset class declarations.
[33807] Fix | Delete
*
[33808] Fix | Delete
* @param {?string} blockSelector
[33809] Fix | Delete
* @param {Object} blockPresets
[33810] Fix | Delete
* @return {string} CSS declarations for the preset classes.
[33811] Fix | Delete
*/
[33812] Fix | Delete
function getPresetsClasses(blockSelector = '*', blockPresets = {}) {
[33813] Fix | Delete
return PRESET_METADATA.reduce((declarations, {
[33814] Fix | Delete
path,
[33815] Fix | Delete
cssVarInfix,
[33816] Fix | Delete
classes
[33817] Fix | Delete
}) => {
[33818] Fix | Delete
if (!classes) {
[33819] Fix | Delete
return declarations;
[33820] Fix | Delete
}
[33821] Fix | Delete
const presetByOrigin = getValueFromObjectPath(blockPresets, path, []);
[33822] Fix | Delete
['default', 'theme', 'custom'].forEach(origin => {
[33823] Fix | Delete
if (presetByOrigin[origin]) {
[33824] Fix | Delete
presetByOrigin[origin].forEach(({
[33825] Fix | Delete
slug
[33826] Fix | Delete
}) => {
[33827] Fix | Delete
classes.forEach(({
[33828] Fix | Delete
classSuffix,
[33829] Fix | Delete
propertyName
[33830] Fix | Delete
}) => {
[33831] Fix | Delete
const classSelectorToUse = `.has-${use_global_styles_output_kebabCase(slug)}-${classSuffix}`;
[33832] Fix | Delete
const selectorToUse = blockSelector.split(',') // Selector can be "h1, h2, h3"
[33833] Fix | Delete
.map(selector => `${selector}${classSelectorToUse}`).join(',');
[33834] Fix | Delete
const value = `var(--wp--preset--${cssVarInfix}--${use_global_styles_output_kebabCase(slug)})`;
[33835] Fix | Delete
declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
[33836] Fix | Delete
});
[33837] Fix | Delete
});
[33838] Fix | Delete
}
[33839] Fix | Delete
});
[33840] Fix | Delete
return declarations;
[33841] Fix | Delete
}, '');
[33842] Fix | Delete
}
[33843] Fix | Delete
function getPresetsSvgFilters(blockPresets = {}) {
[33844] Fix | Delete
return PRESET_METADATA.filter(
[33845] Fix | Delete
// Duotone are the only type of filters for now.
[33846] Fix | Delete
metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
[33847] Fix | Delete
const presetByOrigin = getValueFromObjectPath(blockPresets, metadata.path, {});
[33848] Fix | Delete
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => getDuotoneFilter(`wp-duotone-${preset.slug}`, preset.colors))).join('');
[33849] Fix | Delete
});
[33850] Fix | Delete
}
[33851] Fix | Delete
function flattenTree(input = {}, prefix, token) {
[33852] Fix | Delete
let result = [];
[33853] Fix | Delete
Object.keys(input).forEach(key => {
[33854] Fix | Delete
const newKey = prefix + use_global_styles_output_kebabCase(key.replace('/', '-'));
[33855] Fix | Delete
const newLeaf = input[key];
[33856] Fix | Delete
if (newLeaf instanceof Object) {
[33857] Fix | Delete
const newPrefix = newKey + token;
[33858] Fix | Delete
result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
[33859] Fix | Delete
} else {
[33860] Fix | Delete
result.push(`${newKey}: ${newLeaf}`);
[33861] Fix | Delete
}
[33862] Fix | Delete
});
[33863] Fix | Delete
return result;
[33864] Fix | Delete
}
[33865] Fix | Delete
[33866] Fix | Delete
/**
[33867] Fix | Delete
* Gets variation selector string from feature selector.
[33868] Fix | Delete
*
[33869] Fix | Delete
* @param {string} featureSelector The feature selector.
[33870] Fix | Delete
*
[33871] Fix | Delete
* @param {string} styleVariationSelector The style variation selector.
[33872] Fix | Delete
* @return {string} Combined selector string.
[33873] Fix | Delete
*/
[33874] Fix | Delete
function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) {
[33875] Fix | Delete
const featureSelectors = featureSelector.split(',');
[33876] Fix | Delete
const combinedSelectors = [];
[33877] Fix | Delete
featureSelectors.forEach(selector => {
[33878] Fix | Delete
combinedSelectors.push(`${styleVariationSelector.trim()}${selector.trim()}`);
[33879] Fix | Delete
});
[33880] Fix | Delete
return combinedSelectors.join(', ');
[33881] Fix | Delete
}
[33882] Fix | Delete
[33883] Fix | Delete
/**
[33884] Fix | Delete
* Generate style declarations for a block's custom feature and subfeature
[33885] Fix | Delete
* selectors.
[33886] Fix | Delete
*
[33887] Fix | Delete
* NOTE: The passed `styles` object will be mutated by this function.
[33888] Fix | Delete
*
[33889] Fix | Delete
* @param {Object} selectors Custom selectors object for a block.
[33890] Fix | Delete
* @param {Object} styles A block's styles object.
[33891] Fix | Delete
*
[33892] Fix | Delete
* @return {Object} Style declarations.
[33893] Fix | Delete
*/
[33894] Fix | Delete
const getFeatureDeclarations = (selectors, styles) => {
[33895] Fix | Delete
const declarations = {};
[33896] Fix | Delete
Object.entries(selectors).forEach(([feature, selector]) => {
[33897] Fix | Delete
// We're only processing features/subfeatures that have styles.
[33898] Fix | Delete
if (feature === 'root' || !styles?.[feature]) {
[33899] Fix | Delete
return;
[33900] Fix | Delete
}
[33901] Fix | Delete
const isShorthand = typeof selector === 'string';
[33902] Fix | Delete
[33903] Fix | Delete
// If we have a selector object instead of shorthand process it.
[33904] Fix | Delete
if (!isShorthand) {
[33905] Fix | Delete
Object.entries(selector).forEach(([subfeature, subfeatureSelector]) => {
[33906] Fix | Delete
// Don't process root feature selector yet or any
[33907] Fix | Delete
// subfeature that doesn't have a style.
[33908] Fix | Delete
if (subfeature === 'root' || !styles?.[feature][subfeature]) {
[33909] Fix | Delete
return;
[33910] Fix | Delete
}
[33911] Fix | Delete
[33912] Fix | Delete
// Create a temporary styles object and build
[33913] Fix | Delete
// declarations for subfeature.
[33914] Fix | Delete
const subfeatureStyles = {
[33915] Fix | Delete
[feature]: {
[33916] Fix | Delete
[subfeature]: styles[feature][subfeature]
[33917] Fix | Delete
}
[33918] Fix | Delete
};
[33919] Fix | Delete
const newDeclarations = getStylesDeclarations(subfeatureStyles);
[33920] Fix | Delete
[33921] Fix | Delete
// Merge new declarations in with any others that
[33922] Fix | Delete
// share the same selector.
[33923] Fix | Delete
declarations[subfeatureSelector] = [...(declarations[subfeatureSelector] || []), ...newDeclarations];
[33924] Fix | Delete
[33925] Fix | Delete
// Remove the subfeature's style now it will be
[33926] Fix | Delete
// included under its own selector not the block's.
[33927] Fix | Delete
delete styles[feature][subfeature];
[33928] Fix | Delete
});
[33929] Fix | Delete
}
[33930] Fix | Delete
[33931] Fix | Delete
// Now subfeatures have been processed and removed, we can
[33932] Fix | Delete
// process root, or shorthand, feature selectors.
[33933] Fix | Delete
if (isShorthand || selector.root) {
[33934] Fix | Delete
const featureSelector = isShorthand ? selector : selector.root;
[33935] Fix | Delete
[33936] Fix | Delete
// Create temporary style object and build declarations for feature.
[33937] Fix | Delete
const featureStyles = {
[33938] Fix | Delete
[feature]: styles[feature]
[33939] Fix | Delete
};
[33940] Fix | Delete
const newDeclarations = getStylesDeclarations(featureStyles);
[33941] Fix | Delete
[33942] Fix | Delete
// Merge new declarations with any others that share the selector.
[33943] Fix | Delete
declarations[featureSelector] = [...(declarations[featureSelector] || []), ...newDeclarations];
[33944] Fix | Delete
[33945] Fix | Delete
// Remove the feature from the block's styles now as it will be
[33946] Fix | Delete
// included under its own selector not the block's.
[33947] Fix | Delete
delete styles[feature];
[33948] Fix | Delete
}
[33949] Fix | Delete
});
[33950] Fix | Delete
return declarations;
[33951] Fix | Delete
};
[33952] Fix | Delete
[33953] Fix | Delete
/**
[33954] Fix | Delete
* Transform given style tree into a set of style declarations.
[33955] Fix | Delete
*
[33956] Fix | Delete
* @param {Object} blockStyles Block styles.
[33957] Fix | Delete
*
[33958] Fix | Delete
* @param {string} selector The selector these declarations should attach to.
[33959] Fix | Delete
*
[33960] Fix | Delete
* @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
[33961] Fix | Delete
*
[33962] Fix | Delete
* @param {Object} tree A theme.json tree containing layout definitions.
[33963] Fix | Delete
*
[33964] Fix | Delete
* @param {boolean} disableRootPadding Whether to force disable the root padding styles.
[33965] Fix | Delete
* @return {Array} An array of style declarations.
[33966] Fix | Delete
*/
[33967] Fix | Delete
function getStylesDeclarations(blockStyles = {}, selector = '', useRootPaddingAlign, tree = {}, disableRootPadding = false) {
[33968] Fix | Delete
const isRoot = ROOT_BLOCK_SELECTOR === selector;
[33969] Fix | Delete
const output = Object.entries(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations, [key, {
[33970] Fix | Delete
value,
[33971] Fix | Delete
properties,
[33972] Fix | Delete
useEngine,
[33973] Fix | Delete
rootOnly
[33974] Fix | Delete
}]) => {
[33975] Fix | Delete
if (rootOnly && !isRoot) {
[33976] Fix | Delete
return declarations;
[33977] Fix | Delete
}
[33978] Fix | Delete
const pathToValue = value;
[33979] Fix | Delete
if (pathToValue[0] === 'elements' || useEngine) {
[33980] Fix | Delete
return declarations;
[33981] Fix | Delete
}
[33982] Fix | Delete
const styleValue = getValueFromObjectPath(blockStyles, pathToValue);
[33983] Fix | Delete
[33984] Fix | Delete
// Root-level padding styles don't currently support strings with CSS shorthand values.
[33985] Fix | Delete
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
[33986] Fix | Delete
if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
[33987] Fix | Delete
return declarations;
[33988] Fix | Delete
}
[33989] Fix | Delete
if (properties && typeof styleValue !== 'string') {
[33990] Fix | Delete
Object.entries(properties).forEach(entry => {
[33991] Fix | Delete
const [name, prop] = entry;
[33992] Fix | Delete
if (!getValueFromObjectPath(styleValue, [prop], false)) {
[33993] Fix | Delete
// Do not create a declaration
[33994] Fix | Delete
// for sub-properties that don't have any value.
[33995] Fix | Delete
return;
[33996] Fix | Delete
}
[33997] Fix | Delete
const cssProperty = name.startsWith('--') ? name : use_global_styles_output_kebabCase(name);
[33998] Fix | Delete
declarations.push(`${cssProperty}: ${compileStyleValue(getValueFromObjectPath(styleValue, [prop]))}`);
[33999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function