: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
onSelect: media => selectMedia(media, onClose),
allowedTypes: allowedTypes,
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
children: (0,external_wp_i18n_namespaceObject.__)('Open Media Library')
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormFileUpload, {
uploadFiles(event, onClose);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
children: (0,external_wp_i18n_namespaceObject.__)('Upload')
}), onToggleFeaturedImage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
icon: post_featured_image,
onClick: onToggleFeaturedImage,
isPressed: useFeaturedImage,
children: (0,external_wp_i18n_namespaceObject.__)('Use featured image')
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
(0,external_ReactJSXRuntime_namespaceObject.jsxs)("form", {
className: dist_clsx('block-editor-media-flow__url-input', {
'has-siblings': canUpload || onToggleFeaturedImage
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
className: "block-editor-media-replace-flow__image-url-label",
children: (0,external_wp_i18n_namespaceObject.__)('Current media URL:')
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(link_control, {
editMediaButtonRef.current.focus();
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md
/* harmony default export */ const media_replace_flow = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
} = dispatch(external_wp_notices_namespaceObject.store);
}), (0,external_wp_components_namespaceObject.withFilters)('editor.MediaReplaceFlow')])(MediaReplaceFlow));
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/global-styles/theme-file-uri-utils.js
* Looks up a theme file URI based on a relative path.
* @param {string} file A relative path.
* @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
* @return {string?} A resolved theme file URI, if one is found in the themeFileURIs collection.
function getResolvedThemeFilePath(file, themeFileURIs = []) {
const uri = themeFileURIs.find(themeFileUri => themeFileUri.name === file);
* Mutates an object by settings a value at the provided path.
* @param {Object} object Object to set a value in.
* @param {number|string|Array} path Path in the object to modify.
* @param {*} value New value to set.
* @return {Object} Object with the new value set.
function setMutably(object, path, value) {
const finalValueKey = path.pop();
for (const key of path) {
const current = prev[key];
prev[finalValueKey] = value;
* Resolves any relative paths if a corresponding theme file URI is available.
* Note: this function mutates the object and is specifically to be used in
* an async styles build context in useGlobalStylesOutput
* @param {Object} themeJson Theme.json/Global styles tree.
* @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
* @return {Object} Returns mutated object.
function setThemeFileUris(themeJson, themeFileURIs) {
if (!themeJson?.styles || !themeFileURIs) {
const value = getValueFromObjectPath(themeJson, target);
* The object must not be updated immutably here because the
* themeJson is a reference to the global styles tree used as a dependency in the
* useGlobalStylesOutputWithConfig() hook. If we don't mutate the object,
* the hook will detect the change and re-render the component, resulting
* in a maximum depth exceeded error.
themeJson = setMutably(themeJson, target, href);
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/global-styles/background-panel.js
const IMAGE_BACKGROUND_TYPE = 'image';
const background_panel_DEFAULT_CONTROLS = {
* Checks site settings to see if the background panel may be used.
* `settings.background.backgroundSize` exists also,
* but can only be used if settings?.background?.backgroundImage is `true`.
* @param {Object} settings Site settings
* @return {boolean} Whether site settings has activated background panel.
function useHasBackgroundPanel(settings) {
return external_wp_element_namespaceObject.Platform.OS === 'web' && settings?.background?.backgroundImage;
* Checks if there is a current value in the background size block support
* attributes. Background size values include background size as well
* as background position.
* @param {Object} style Style attribute.
* @return {boolean} Whether the block has a background size value set.
function hasBackgroundSizeValue(style) {
return style?.background?.backgroundPosition !== undefined || style?.background?.backgroundSize !== undefined;
* Checks if there is a current value in the background image block support
* @param {Object} style Style attribute.
* @return {boolean} Whether the block has a background image value set.
function hasBackgroundImageValue(style) {
return !!style?.background?.backgroundImage?.id ||
// Supports url() string values in theme.json.
'string' === typeof style?.background?.backgroundImage || !!style?.background?.backgroundImage?.url;
* Get the help text for the background size control.
* @param {string} value backgroundSize value.
* @return {string} Translated help text.
function backgroundSizeHelpText(value) {
if (value === 'cover' || value === undefined) {
return (0,external_wp_i18n_namespaceObject.__)('Image covers the space evenly.');
if (value === 'contain') {
return (0,external_wp_i18n_namespaceObject.__)('Image is contained without distortion.');
return (0,external_wp_i18n_namespaceObject.__)('Image has a fixed width.');
* Converts decimal x and y coords from FocalPointPicker to percentage-based values
* to use as backgroundPosition value.
* @param {{x?:number, y?:number}} value FocalPointPicker coords.
* @return {string} backgroundPosition value.
const coordsToBackgroundPosition = value => {
if (!value || isNaN(value.x) && isNaN(value.y)) {
const x = isNaN(value.x) ? 0.5 : value.x;
const y = isNaN(value.y) ? 0.5 : value.y;
return `${x * 100}% ${y * 100}%`;
* Converts backgroundPosition value to x and y coords for FocalPointPicker.
* @param {string} value backgroundPosition value.
* @return {{x?:number, y?:number}} FocalPointPicker coords.
const backgroundPositionToCoords = value => {
let [x, y] = value.split(' ').map(v => parseFloat(v) / 100);
x = isNaN(x) ? undefined : x;
function InspectorImagePreview({
const imgLabel = label || (0,external_wp_url_namespaceObject.getFilename)(imgUrl) || (0,external_wp_i18n_namespaceObject.__)('Add background image');
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalItemGroup, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
justify: imgUrl ? 'flex-start' : 'center',
children: [imgUrl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
className: dist_clsx('block-editor-global-styles-background-panel__inspector-image-indicator-wrapper', {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
className: "block-editor-global-styles-background-panel__inspector-image-indicator",
backgroundImage: `url(${imgUrl})`
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.FlexItem, {
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTruncate, {
className: "block-editor-global-styles-background-panel__inspector-media-replace-title",
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
children: imgUrl ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: file name */
(0,external_wp_i18n_namespaceObject.__)('Background image: %s'), filename || imgLabel) : (0,external_wp_i18n_namespaceObject.__)('No background image selected')
function BackgroundImageToolsPanelItem({
const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSettings().mediaUpload, []);
} = style?.background?.backgroundImage || {
...inheritedValue?.background?.backgroundImage
const replaceContainerRef = (0,external_wp_element_namespaceObject.useRef)();
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
const onUploadError = message => {
createErrorNotice(message, {
const resetBackgroundImage = () => onChange(setImmutably(style, ['background', 'backgroundImage'], undefined));
const onSelectMedia = media => {
if (!media || !media.url) {
if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) {
// For media selections originated from a file upload.
if (media.media_type && media.media_type !== IMAGE_BACKGROUND_TYPE || !media.media_type && media.type && media.type !== IMAGE_BACKGROUND_TYPE) {
onUploadError((0,external_wp_i18n_namespaceObject.__)('Only images can be used as a background image.'));
const sizeValue = style?.background?.backgroundSize;
const positionValue = style?.background?.backgroundPosition;
onChange(setImmutably(style, ['background'], {
title: media.title || undefined
backgroundPosition: !positionValue && ('auto' === sizeValue || !sizeValue) ? '50% 0' : positionValue
const onFilesDrop = filesList => {
allowedTypes: [IMAGE_BACKGROUND_TYPE],
if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) {
const resetAllFilter = (0,external_wp_element_namespaceObject.useCallback)(previousValue => {
const hasValue = hasBackgroundImageValue(style);
const closeAndFocus = () => {
const [toggleButton] = external_wp_dom_namespaceObject.focus.tabbable.find(replaceContainerRef.current);
// Focus the toggle button and close the dropdown menu.
// This ensures similar behaviour as to selecting an image, where the dropdown is
// closed and focus is redirected to the dropdown toggle button.
const onRemove = () => onChange(setImmutably(style, ['background', 'backgroundImage'], 'none'));
const canRemove = !hasValue && hasBackgroundImageValue(inheritedValue);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
className: "single-column",
hasValue: () => hasValue,
label: (0,external_wp_i18n_namespaceObject.__)('Background image'),
onDeselect: resetBackgroundImage,
isShownByDefault: isShownByDefault,
resetAllFilter: resetAllFilter,
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
className: "block-editor-global-styles-background-panel__inspector-media-replace-container",
ref: replaceContainerRef,
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(media_replace_flow, {
allowedTypes: [IMAGE_BACKGROUND_TYPE],
name: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InspectorImagePreview, {
url: getResolvedThemeFilePath(url, themeFileURIs)
children: [canRemove && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
children: (0,external_wp_i18n_namespaceObject.__)('Remove')
}), hasValue && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
children: (0,external_wp_i18n_namespaceObject.__)('Reset ')
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropZone, {
onFilesDrop: onFilesDrop,
label: (0,external_wp_i18n_namespaceObject.__)('Drop to upload')
function BackgroundSizeToolsPanelItem({
const sizeValue = style?.background?.backgroundSize || inheritedValue?.background?.backgroundSize;
const repeatValue = style?.background?.backgroundRepeat || inheritedValue?.background?.backgroundRepeat;
const imageValue = style?.background?.backgroundImage?.url || inheritedValue?.background?.backgroundImage?.url;
const positionValue = style?.background?.backgroundPosition || inheritedValue?.background?.backgroundPosition;
* An `undefined` value is replaced with any supplied
* default control value for the toggle group control.
* An empty string is treated as `auto` - this allows a user
* to select "Size" and then enter a custom value, with an
* empty value being treated as `auto`.
const currentValueForToggle = sizeValue !== undefined && sizeValue !== 'cover' && sizeValue !== 'contain' || sizeValue === '' ? 'auto' : sizeValue || defaultValues?.backgroundSize;
* If the current value is `cover` and the repeat value is `undefined`, then
* the toggle should be unchecked as the default state. Otherwise, the toggle
* should reflect the current repeat value.
const repeatCheckedValue = !(repeatValue === 'no-repeat' || currentValueForToggle === 'cover' && repeatValue === undefined);
const hasValue = hasBackgroundSizeValue(style);
const resetAllFilter = (0,external_wp_element_namespaceObject.useCallback)(previousValue => {
...previousValue.style?.background,
backgroundRepeat: undefined,
backgroundSize: undefined
const updateBackgroundSize = next => {
// When switching to 'contain' toggle the repeat off.
let nextRepeat = repeatValue;
let nextPosition = positionValue;
if (next === 'contain') {
nextRepeat = 'no-repeat';
nextPosition = undefined;
nextPosition = undefined;
if ((currentValueForToggle === 'cover' || currentValueForToggle === 'contain') && next === 'auto') {
* A background image uploaded and set in the editor (an image with a record id),
* receives a default background position of '50% 0',
* when the toggle switches to "Tile". This is to increase the chance that