UNPKG

@wordpress/block-library

Version:
1 lines • 41.8 kB
{"version":3,"file":"index.cjs","names":["unlock","blockEditorPrivateApis","__","isBlobURL","useEntityProp","useSelect","blockEditorStore","useDispatch","useRegistry","useEvent","coreStore","getMediaColor","compositeIsDark","IMAGE_BACKGROUND_TYPE","noticesStore","__experimentalUseGradient","createBlocksFromInnerBlocksTemplate","attributesFromMedia","DEFAULT_MEDIA_SIZE_SLUG","DEFAULT_OVERLAY_COLOR","DEFAULT_BACKGROUND_COLOR","EMBED_VIDEO_BACKGROUND_TYPE","useReducedMotion","useMemo","getBackgroundEmbedHtml","useState","VIDEO_BACKGROUND_TYPE","useBlockEditingMode","useResizeObserver","useSettings","parseQuantityAndUnitFromRawValue","mediaPosition","useRef","useBlockProps","useMergeRefs","useInnerBlocksProps","useCallback","CoverBlockControls","CoverInspectorControls","ResizableCoverPopover","CoverPlaceholder","ColorPalette","isContentPositionCenter","getPositionClassName","Placeholder","SandBox","WCSpinner","dimRatioToClass","compose","withColors"],"sources":["../../../src/cover/edit/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport {\n\tPlaceholder,\n\tSandBox,\n\tSpinner as WCSpinner,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tuseEvent,\n\tuseMergeRefs,\n\tuseReducedMotion,\n\tuseResizeObserver,\n} from '@wordpress/compose';\nimport {\n\twithColors,\n\tColorPalette,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n\tuseBlockEditingMode,\n\tuseSettings,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tEMBED_VIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from '../shared';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCoverPopover from './resizable-cover-popover';\nimport {\n\tgetMediaColor,\n\tcompositeIsDark,\n\tDEFAULT_BACKGROUND_COLOR,\n\tDEFAULT_OVERLAY_COLOR,\n} from './color-utils';\nimport { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';\nimport { getBackgroundEmbedHtml } from '../embed-video-utils';\nimport { unlock } from '../../lock-unlock';\n\nconst { openMediaEditorModalKey, cleanEmptyObject } = unlock(\n\tblockEditorPrivateApis\n);\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\tstyle: {\n\t\t\t\t\ttypography: {\n\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: __( 'Write title…' ),\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t],\n\t];\n}\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily while\n * the media (image or video) is being uploaded and will not have an id allocated yet.\n *\n * @param {number} id The id of the media.\n * @param {string} url The url of the media.\n *\n * @return {boolean} Is the URL a Blob URL.\n */\nconst isTemporaryMedia = ( id, url ) => ! id && isBlobURL( url );\n\nfunction CoverEdit( {\n\tattributes,\n\tclientId,\n\tisSelected,\n\toverlayColor,\n\tsetAttributes,\n\tsetOverlayColor,\n\ttoggleSelection,\n\tcontext: { postId, postType },\n} ) {\n\tconst {\n\t\tcontentPosition,\n\t\tid,\n\t\turl: originalUrl,\n\t\tbackgroundType: originalBackgroundType,\n\t\tuseFeaturedImage,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\tstyle,\n\t\talt,\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t\ttagName: TagName = 'div',\n\t\tisUserOverlayColor,\n\t\tsizeSlug,\n\t\tposter,\n\t} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst openMediaEditorModal = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()[ openMediaEditorModalKey ],\n\t\t[]\n\t);\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\t// Reads the latest values after async operations (e.g. getMediaColor),\n\t// avoiding stale values that could overwrite concurrent remote changes.\n\tconst getLatestProps = useEvent( () => ( { attributes, overlayColor } ) );\n\n\tconst { media } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage && useFeaturedImage\n\t\t\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\tfeaturedImage,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, useFeaturedImage ]\n\t);\n\tconst mediaUrl =\n\t\tmedia?.media_details?.sizes?.[ sizeSlug ]?.source_url ??\n\t\tmedia?.source_url;\n\n\t// User can change the featured image outside of the block, but we still\n\t// need to update the block when that happens. This effect should only\n\t// run when the featured image changes in that case. All other cases are\n\t// handled in their respective callbacks.\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tif ( ! useFeaturedImage ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst averageBackgroundColor = await getMediaColor( mediaUrl );\n\n\t\t\t// Read latest values after await to avoid stale closures.\n\t\t\tconst { attributes: currentAttrs, overlayColor: currentOverlay } =\n\t\t\t\tgetLatestProps();\n\n\t\t\tlet newOverlayColor = currentOverlay.color;\n\t\t\tif ( ! currentAttrs.isUserOverlayColor ) {\n\t\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t}\n\n\t\t\tconst newIsDark = compositeIsDark(\n\t\t\t\tcurrentAttrs.dimRatio,\n\t\t\t\tnewOverlayColor,\n\t\t\t\taverageBackgroundColor\n\t\t\t);\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tisDark: newIsDark,\n\t\t\t\tisUserOverlayColor: currentAttrs.isUserOverlayColor || false,\n\t\t\t} );\n\t\t} )();\n\t\t// Update the block only when the featured image changes.\n\t\t// The other dependencies are stable references (dispatch actions / setters).\n\t}, [\n\t\tmediaUrl,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetAttributes,\n\t\tsetOverlayColor,\n\t\tuseFeaturedImage,\n\t\tgetLatestProps,\n\t] );\n\n\t// instead of destructuring the attributes\n\t// we define the url and background type\n\t// depending on the value of the useFeaturedImage flag\n\t// to preview in edit the dynamic featured image\n\tconst url = useFeaturedImage\n\t\t? mediaUrl\n\t\t: // Ensure the url is not malformed due to sanitization through `wp_kses`.\n\t\t\toriginalUrl?.replaceAll( '&amp;', '&' );\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: originalBackgroundType;\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\n\t// Create the initial inner paragraph when the block gains a background\n\t// and has no content yet.\n\tconst scaffoldInnerBlocks = () => {\n\t\tconst {\n\t\t\tgetBlocks,\n\t\t\tisBlockSelected,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t} = registry.select( blockEditorStore );\n\t\tif ( getBlocks( clientId ).length > 0 ) {\n\t\t\treturn;\n\t\t}\n\t\t// Check for fontSize support before we pass a fontSize attribute to\n\t\t// the innerBlocks.\n\t\tconst [ fontSizes ] = unlock(\n\t\t\tregistry.select( blockEditorStore )\n\t\t).getBlockSettings( clientId, 'typography.fontSizes' );\n\t\tconst hasFontSizes = fontSizes?.length > 0;\n\t\treplaceInnerBlocks(\n\t\t\tclientId,\n\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\tgetInnerBlocksTemplate( {\n\t\t\t\t\tfontSize: hasFontSizes ? 'large' : undefined,\n\t\t\t\t} )\n\t\t\t),\n\t\t\tisBlockSelected( clientId ),\n\t\t\tgetSelectedBlocksInitialCaretPosition()\n\t\t);\n\t};\n\n\tconst onSelectMedia = async ( newMedia ) => {\n\t\tconst mediaAttributes = attributesFromMedia( newMedia );\n\t\tconst isImage = [ newMedia?.type, newMedia?.media_type ].includes(\n\t\t\tIMAGE_BACKGROUND_TYPE\n\t\t);\n\n\t\tconst averageBackgroundColor = await getMediaColor(\n\t\t\tisImage ? newMedia?.url : undefined\n\t\t);\n\n\t\t// Read latest values to avoid stale closures.\n\t\tconst { attributes: currentAttrs, overlayColor: currentOverlay } =\n\t\t\tgetLatestProps();\n\n\t\tlet newOverlayColor = currentOverlay.color;\n\t\tif ( ! currentAttrs.isUserOverlayColor ) {\n\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t// Fold next attribute change into the same undo level as the setOverlayColor above.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\t// Only set a new dimRatio if there was no previous media selected\n\t\t// to avoid resetting to 50 if it has been explicitly set to 100.\n\t\t// See issue #52835 for context.\n\t\tconst newDimRatio =\n\t\t\tcurrentAttrs.url === undefined && currentAttrs.dimRatio === 100\n\t\t\t\t? 50\n\t\t\t\t: currentAttrs.dimRatio;\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tif ( backgroundType === IMAGE_BACKGROUND_TYPE && mediaAttributes?.id ) {\n\t\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t\t// Try to use the previous selected image size if it's available\n\t\t\t// otherwise try the default image size or fallback to full size.\n\t\t\tif (\n\t\t\t\tsizeSlug &&\n\t\t\t\t( newMedia?.sizes?.[ sizeSlug ] ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ sizeSlug ] )\n\t\t\t) {\n\t\t\t\tmediaAttributes.sizeSlug = sizeSlug;\n\t\t\t\tmediaAttributes.url =\n\t\t\t\t\tnewMedia?.sizes?.[ sizeSlug ]?.url ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ sizeSlug ]?.source_url;\n\t\t\t} else if (\n\t\t\t\tnewMedia?.sizes?.[ imageDefaultSize ] ||\n\t\t\t\tnewMedia?.media_details?.sizes?.[ imageDefaultSize ]\n\t\t\t) {\n\t\t\t\tmediaAttributes.sizeSlug = imageDefaultSize;\n\t\t\t\tmediaAttributes.url =\n\t\t\t\t\tnewMedia?.sizes?.[ imageDefaultSize ]?.url ||\n\t\t\t\t\tnewMedia?.media_details?.sizes?.[ imageDefaultSize ]\n\t\t\t\t\t\t?.source_url;\n\t\t\t} else {\n\t\t\t\tmediaAttributes.sizeSlug = DEFAULT_MEDIA_SIZE_SLUG;\n\t\t\t}\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( {\n\t\t\t\t...mediaAttributes,\n\t\t\t\tfocalPoint: undefined,\n\t\t\t\tuseFeaturedImage: undefined,\n\t\t\t\tdimRatio: newDimRatio,\n\t\t\t\tisDark: newIsDark,\n\t\t\t\tisUserOverlayColor: currentAttrs.isUserOverlayColor || false,\n\t\t\t} );\n\n\t\t\tscaffoldInnerBlocks();\n\t\t} );\n\t};\n\n\tconst onClearMedia = () => {\n\t\tlet newOverlayColor = overlayColor.color;\n\n\t\t// Skip for embeds, which never auto-assign an overlay color; otherwise\n\t\t// the non-persistent flag lands on the media reset itself (unsaveable).\n\t\tif ( ! isUserOverlayColor && overlayColor.color ) {\n\t\t\tnewOverlayColor = DEFAULT_OVERLAY_COLOR;\n\t\t\tsetOverlayColor( undefined );\n\t\t\t// Fold next attribute change into the same undo level as the setOverlayColor above.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tdimRatio,\n\t\t\tnewOverlayColor,\n\t\t\tDEFAULT_BACKGROUND_COLOR\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tid: undefined,\n\t\t\tbackgroundType: undefined,\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tisRepeated: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onSetOverlayColor = async ( newOverlayColor ) => {\n\t\tconst averageBackgroundColor = await getMediaColor( url );\n\n\t\t// Read latest dimRatio after await to avoid stale closure.\n\t\tconst { attributes: currentAttrs } = getLatestProps();\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tcurrentAttrs.dimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetOverlayColor( newOverlayColor );\n\t\t// Fold next attribute change into the same undo level as the setOverlayColor above.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( {\n\t\t\t\tisUserOverlayColor: true,\n\t\t\t\tisDark: newIsDark,\n\t\t\t} );\n\n\t\t\t// Skip when the color is cleared: that returns the block to its\n\t\t\t// placeholder, which only renders while there is no content.\n\t\t\tif ( newOverlayColor ) {\n\t\t\t\tscaffoldInnerBlocks();\n\t\t\t}\n\t\t} );\n\t};\n\n\tconst onUpdateDimRatio = async ( newDimRatio ) => {\n\t\tconst averageBackgroundColor = await getMediaColor( url );\n\n\t\t// Read latest overlayColor after await to avoid stale closure.\n\t\tconst { overlayColor: currentOverlay } = getLatestProps();\n\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tcurrentOverlay.color,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tsetAttributes( {\n\t\t\tdimRatio: newDimRatio,\n\t\t\tisDark: newIsDark,\n\t\t} );\n\t};\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectEmbedUrl = ( embedUrl ) => {\n\t\t// Only set a new dimRatio if there was no previous media selected\n\t\t// to avoid resetting to 50 if it has been explicitly set to 100.\n\t\tconst newDimRatio =\n\t\t\toriginalUrl === undefined && dimRatio === 100 ? 50 : dimRatio;\n\n\t\t// Set initial attributes with URL\n\t\tsetAttributes( {\n\t\t\turl: embedUrl,\n\t\t\tbackgroundType: EMBED_VIDEO_BACKGROUND_TYPE,\n\t\t\tdimRatio: newDimRatio,\n\t\t\tid: undefined,\n\t\t\tfocalPoint: undefined,\n\t\t\thasParallax: undefined,\n\t\t\tisRepeated: undefined,\n\t\t\tuseFeaturedImage: undefined,\n\t\t} );\n\t};\n\n\t// Fetch embed preview for embed videos\n\tconst { embedPreview, isFetchingEmbed } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( backgroundType !== EMBED_VIDEO_BACKGROUND_TYPE || ! url ) {\n\t\t\t\treturn {\n\t\t\t\t\tembedPreview: undefined,\n\t\t\t\t\tisFetchingEmbed: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getEmbedPreview, isRequestingEmbedPreview } =\n\t\t\t\tselect( coreStore );\n\n\t\t\treturn {\n\t\t\t\tembedPreview: getEmbedPreview( url ),\n\t\t\t\tisFetchingEmbed: isRequestingEmbedPreview( url ),\n\t\t\t};\n\t\t},\n\t\t[ url, backgroundType ]\n\t);\n\n\tconst prefersReducedMotion = useReducedMotion();\n\n\t// Compute embed HTML for editor display via SandBox\n\tconst embedHtml = useMemo( () => {\n\t\tif (\n\t\t\tbackgroundType !== EMBED_VIDEO_BACKGROUND_TYPE ||\n\t\t\t! embedPreview?.html\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\treturn getBackgroundEmbedHtml( embedPreview.html, {\n\t\t\tautoplay: ! prefersReducedMotion,\n\t\t} );\n\t}, [ embedPreview, backgroundType, prefersReducedMotion ] );\n\n\t// Set while the media editor has pointed the cover at a freshly\n\t// generated file the browser hasn't finished loading; cleared by the\n\t// background <img> load/error handlers (or immediately after\n\t// setAttributes for CSS backgrounds, which never fire load events).\n\tconst [ isSwappingMedia, setIsSwappingMedia ] = useState( false );\n\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\tconst isEmbedVideoBackground =\n\t\tEMBED_VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tconst [ resizeListener, { height, width } ] = useResizeObserver();\n\tconst [ isMinHeightEnabled ] = useSettings( 'dimensions.minHeight' );\n\tconst minHeight = style?.dimensions?.minHeight;\n\tconst resizableBoxDimensions = useMemo( () => {\n\t\tconst [ quantity, unit ] = parseQuantityAndUnitFromRawValue(\n\t\t\tminHeight ?? ''\n\t\t);\n\t\treturn {\n\t\t\theight: unit === 'px' && quantity ? quantity : 'auto',\n\t\t\twidth: 'auto',\n\t\t};\n\t}, [ minHeight ] );\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst bgStyle = { backgroundColor: overlayColor.color };\n\tconst mediaStyle = {\n\t\tobjectPosition:\n\t\t\tfocalPoint && isImgElement\n\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t: undefined,\n\t};\n\n\tconst hasBackground = !! ( url || overlayColor.color || gradientValue );\n\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlock( clientId ).innerBlocks.length >\n\t\t\t0,\n\t\t[ clientId ]\n\t);\n\n\tconst ref = useRef();\n\t// State, not a ref, so that the element is there on the next render.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ ref, setDropZoneElement ] ),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t},\n\t\t{\n\t\t\tallowedBlocks,\n\t\t\ttemplateLock,\n\t\t\tdropZoneElement,\n\t\t}\n\t);\n\n\tconst mediaElement = useRef();\n\tconst editMediaButtonRef = useRef();\n\n\t// `autoPlay` only applies when the video loads, so pause a video that is\n\t// already playing when the user turns on reduced motion.\n\tuseEffect( () => {\n\t\tif ( prefersReducedMotion && isVideoBackground ) {\n\t\t\tmediaElement.current?.pause();\n\t\t}\n\t}, [ prefersReducedMotion, isVideoBackground ] );\n\tconst currentSettings = {\n\t\tisVideoBackground,\n\t\tisImageBackground,\n\t\tmediaElement,\n\t\thasInnerBlocks,\n\t\turl,\n\t\tisImgElement,\n\t\toverlayColor,\n\t};\n\n\tconst openCoverMediaEditorModal = useCallback( () => {\n\t\tif ( ! id || ! openMediaEditorModal ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst previousImage = { id, url: getLatestProps().attributes.url };\n\t\tlet isUndone = false;\n\t\topenMediaEditorModal( {\n\t\t\tid,\n\t\t\tonClose: () => {\n\t\t\t\teditMediaButtonRef.current?.focus();\n\t\t\t},\n\t\t\tonUndo: () => {\n\t\t\t\tisUndone = true;\n\t\t\t\tsetIsSwappingMedia( false );\n\t\t\t\tsetAttributes( previousImage );\n\t\t\t},\n\t\t\tonUpdate: async ( { id: newId, url: newUrl } ) => {\n\t\t\t\tif ( typeof newId !== 'number' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( newId !== id && newUrl ) {\n\t\t\t\t\tsetIsSwappingMedia( true );\n\t\t\t\t}\n\n\t\t\t\tconst nextAttributes = {\n\t\t\t\t\tid: newId,\n\t\t\t\t\tbackgroundType: IMAGE_BACKGROUND_TYPE,\n\t\t\t\t\t...( newUrl ? { url: newUrl } : {} ),\n\t\t\t\t\t...( newId !== id\n\t\t\t\t\t\t? { sizeSlug: DEFAULT_MEDIA_SIZE_SLUG }\n\t\t\t\t\t\t: {} ),\n\t\t\t\t};\n\n\t\t\t\tif ( newUrl ) {\n\t\t\t\t\tconst averageBackgroundColor =\n\t\t\t\t\t\tawait getMediaColor( newUrl );\n\t\t\t\t\t// Snackbar Undo can run while the image color is loading.\n\t\t\t\t\tif ( isUndone ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Read latest values after await to avoid stale closures.\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes: currentAttrs,\n\t\t\t\t\t\toverlayColor: currentOverlay,\n\t\t\t\t\t} = getLatestProps();\n\n\t\t\t\t\tlet newOverlayColor = currentOverlay.color;\n\t\t\t\t\tif ( ! currentAttrs.isUserOverlayColor ) {\n\t\t\t\t\t\tnewOverlayColor = averageBackgroundColor;\n\t\t\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t\t\t\t// Fold next attribute change into the same undo level as the setOverlayColor above.\n\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t}\n\n\t\t\t\t\tnextAttributes.isDark = compositeIsDark(\n\t\t\t\t\t\tcurrentAttrs.dimRatio,\n\t\t\t\t\t\tnewOverlayColor,\n\t\t\t\t\t\taverageBackgroundColor\n\t\t\t\t\t);\n\t\t\t\t\tnextAttributes.isUserOverlayColor =\n\t\t\t\t\t\tcurrentAttrs.isUserOverlayColor || false;\n\t\t\t\t}\n\n\t\t\t\tsetAttributes( nextAttributes );\n\n\t\t\t\t// A CSS background (parallax/repeated) renders as a div and\n\t\t\t\t// never fires a load event; getMediaColor already fetched\n\t\t\t\t// the file, so the swap is done once attributes are set.\n\t\t\t\tconst {\n\t\t\t\t\thasParallax: currentHasParallax,\n\t\t\t\t\tisRepeated: currentIsRepeated,\n\t\t\t\t} = getLatestProps().attributes;\n\t\t\t\tif ( currentHasParallax || currentIsRepeated ) {\n\t\t\t\t\tsetIsSwappingMedia( false );\n\t\t\t\t}\n\t\t\t},\n\t\t} );\n\t}, [\n\t\tid,\n\t\tgetLatestProps,\n\t\topenMediaEditorModal,\n\t\tsetAttributes,\n\t\tsetOverlayColor,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst showEditMediaButton =\n\t\thasNonContentControls &&\n\t\t! useFeaturedImage &&\n\t\tisImageBackground &&\n\t\t!! id &&\n\t\t!! url &&\n\t\t! isUploadingMedia &&\n\t\t!! openMediaEditorModal;\n\n\tconst toggleUseFeaturedImage = async () => {\n\t\tconst newUseFeaturedImage = ! useFeaturedImage;\n\n\t\tconst averageBackgroundColor = newUseFeaturedImage\n\t\t\t? await getMediaColor( mediaUrl )\n\t\t\t: DEFAULT_BACKGROUND_COLOR;\n\n\t\t// Read latest values after await to avoid stale closures.\n\t\tconst { attributes: currentAttrs, overlayColor: currentOverlay } =\n\t\t\tgetLatestProps();\n\n\t\tconst newOverlayColor = ! currentAttrs.isUserOverlayColor\n\t\t\t? averageBackgroundColor\n\t\t\t: currentOverlay.color;\n\n\t\tif ( ! currentAttrs.isUserOverlayColor ) {\n\t\t\tif ( newUseFeaturedImage ) {\n\t\t\t\tsetOverlayColor( newOverlayColor );\n\t\t\t} else {\n\t\t\t\tsetOverlayColor( undefined );\n\t\t\t}\n\t\t\t// Fold next attribute change into the same undo level as the setOverlayColor above.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t}\n\n\t\tconst newDimRatio =\n\t\t\tcurrentAttrs.dimRatio === 100 ? 50 : currentAttrs.dimRatio;\n\t\tconst newIsDark = compositeIsDark(\n\t\t\tnewDimRatio,\n\t\t\tnewOverlayColor,\n\t\t\taverageBackgroundColor\n\t\t);\n\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( {\n\t\t\t\tid: undefined,\n\t\t\t\turl: undefined,\n\t\t\t\tuseFeaturedImage: newUseFeaturedImage,\n\t\t\t\tdimRatio: newDimRatio,\n\t\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t\t: undefined,\n\t\t\t\tisDark: newIsDark,\n\t\t\t} );\n\n\t\t\t// Skip when the featured image is disabled: that can return the\n\t\t\t// block to its placeholder, which only renders while there is no\n\t\t\t// content.\n\t\t\tif ( newUseFeaturedImage ) {\n\t\t\t\tscaffoldInnerBlocks();\n\t\t\t}\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tonSelectEmbedUrl={ onSelectEmbedUrl }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tonClearMedia={ onClearMedia }\n\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\tonEditMedia={ openCoverMediaEditorModal }\n\t\t\teditMediaButtonRef={ editMediaButtonRef }\n\t\t\tshowEditMediaButton={ showEditMediaButton }\n\t\t\tisEditMediaDisabled={ isSwappingMedia }\n\t\t/>\n\t);\n\n\tconst inspectorControls = (\n\t\t<CoverInspectorControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tclientId={ clientId }\n\t\t\tsetOverlayColor={ onSetOverlayColor }\n\t\t\tcoverRef={ ref }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tonUploadError={ onUploadError }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tupdateDimRatio={ onUpdateDimRatio }\n\t\t\tonClearMedia={ onClearMedia }\n\t\t\tfeaturedImage={ media }\n\t\t\tisSelected={ isSelected }\n\t\t/>\n\t);\n\n\tconst setMinHeight = ( value ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tdimensions: {\n\t\t\t\t\t...style?.dimensions,\n\t\t\t\t\tminHeight: value === undefined ? undefined : `${ value }px`,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst resizableCoverProps = {\n\t\tclassName: 'block-library-cover__resize-container',\n\t\tclientId,\n\t\theight,\n\t\tminHeight,\n\t\tonResizeStart: () => {\n\t\t\ttoggleSelection( false );\n\t\t},\n\t\tonResize: setMinHeight,\n\t\tonResizeStop: ( newMinHeight ) => {\n\t\t\ttoggleSelection( true );\n\t\t\tsetMinHeight( newMinHeight );\n\t\t},\n\t\t// Hide the resize handle if an aspect ratio is set, as the aspect ratio takes precedence.\n\t\tshowHandle: ! style?.dimensions?.aspectRatio,\n\t\tsize: resizableBoxDimensions,\n\t\twidth,\n\t};\n\n\tif ( ! useFeaturedImage && ! hasInnerBlocks && ! hasBackground ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockControls }\n\t\t\t\t{ inspectorControls }\n\t\t\t\t{ hasNonContentControls && isSelected && isMinHeightEnabled && (\n\t\t\t\t\t<ResizableCoverPopover { ...resizableCoverProps } />\n\t\t\t\t) }\n\t\t\t\t<TagName\n\t\t\t\t\t{ ...blockProps }\n\t\t\t\t\tclassName={ clsx( 'is-placeholder', blockProps.className ) }\n\t\t\t\t>\n\t\t\t\t\t{ resizeListener }\n\t\t\t\t\t<CoverPlaceholder\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"wp-block-cover__placeholder-background-options\">\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tdisableCustomColors\n\t\t\t\t\t\t\t\tvalue={ overlayColor.color }\n\t\t\t\t\t\t\t\tonChange={ onSetOverlayColor }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tpresentation=\"toggle-buttons\"\n\t\t\t\t\t\t\t\taria-label={ __( 'Overlay color' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</CoverPlaceholder>\n\t\t\t\t</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst classes = clsx(\n\t\t{\n\t\t\t'is-dark-theme': isDark,\n\t\t\t'is-light': ! isDark,\n\t\t\t'is-transient': isUploadingMedia || isSwappingMedia,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\tconst showOverlay =\n\t\turl || ! useFeaturedImage || ( useFeaturedImage && ! url );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ clsx( classes, blockProps.className ) }\n\t\t\t\tdata-url={ url }\n\t\t\t>\n\t\t\t\t{ resizeListener }\n\n\t\t\t\t{ ! url && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-cover__image--placeholder-image\"\n\t\t\t\t\t\twithIllustration\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ url &&\n\t\t\t\t\tisImageBackground &&\n\t\t\t\t\t( isImgElement ? (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\tclassName=\"wp-block-cover__image-background\"\n\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t\t\tonLoad={ () => setIsSwappingMedia( false ) }\n\t\t\t\t\t\t\tonError={ () => setIsSwappingMedia( false ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\trole={ alt ? 'img' : undefined }\n\t\t\t\t\t\t\taria-label={ alt ? alt : undefined }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t'wp-block-cover__image-background'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ { backgroundImage, backgroundPosition } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ url && isVideoBackground && (\n\t\t\t\t\t<video\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background\"\n\t\t\t\t\t\tautoPlay={ ! prefersReducedMotion }\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tloop\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isEmbedVideoBackground && embedHtml && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background wp-block-cover__embed-background\"\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t>\n\t\t\t\t\t\t<SandBox\n\t\t\t\t\t\t\tallowSameOrigin\n\t\t\t\t\t\t\thtml={ embedHtml }\n\t\t\t\t\t\t\ttitle=\"Background video\"\n\t\t\t\t\t\t\tstyles={ [\n\t\t\t\t\t\t\t\t'iframe{position:fixed;top:0;left:0;width:100%;height:100%;}',\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ isEmbedVideoBackground && ! embedHtml && isFetchingEmbed && (\n\t\t\t\t\t<WCSpinner />\n\t\t\t\t) }\n\n\t\t\t\t{ showOverlay && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ { backgroundImage: gradientValue, ...bgStyle } }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ ( isUploadingMedia || isSwappingMedia ) && <WCSpinner /> }\n\n\t\t\t\t<CoverPlaceholder\n\t\t\t\t\tdisableMediaButtons\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</TagName>\n\t\t\t{ hasNonContentControls && isSelected && isMinHeightEnabled && (\n\t\t\t\t<ResizableCoverPopover { ...resizableCoverProps } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( CoverEdit );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAM,EAAE,yBAAyB,sBAAA,GAAqBA,qBAAAA,OAAAA,CACrDC,wBAAAA,WACD;AAEA,SAAS,uBAAwB,YAAa;CAC7C,OAAO,CACN,CACC,kBACA;EACC,OAAO,EACN,YAAY,EACX,WAAW,SACZ,EACD;EACA,cAAA,GAAaC,gBAAAA,GAAAA,CAAI,cAAe;EAChC,GAAG;CACJ,CACD,CACD;AACD;;;;;;;;;;AAWA,MAAM,oBAAqB,IAAI,QAAS,CAAE,OAAA,GAAMC,gBAAAA,UAAAA,CAAW,GAAI;AAE/D,SAAS,UAAW,EACnB,YACA,UACA,YACA,cACA,eACA,iBACA,iBACA,SAAS,EAAE,QAAQ,cAChB;CACH,MAAM,EACL,iBACA,IACA,KAAK,aACL,gBAAgB,wBAChB,kBACA,UACA,YACA,aACA,QACA,YACA,OACA,KACA,eACA,cACA,SAAS,UAAU,OACnB,oBACA,UACA,WACG;CAEJ,MAAM,CAAE,kBAAA,GAAkBC,qBAAAA,cAAAA,CACzB,YACA,UACA,kBACA,MACD;CACA,MAAM,EAAE,iBAAA,GAAgBC,gBAAAA,UAAAA,CAAWC,wBAAAA,KAAiB;CACpD,MAAM,wBAAA,GAAuBD,gBAAAA,UAAAA,EAC1B,WACD,OAAQC,wBAAAA,KAAiB,CAAC,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