@wordpress/block-library 8.28.4 → 8.28.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/block/deprecated.js +71 -11
- package/build/block/deprecated.js.map +1 -1
- package/build/block/edit.js +65 -31
- package/build/block/edit.js.map +1 -1
- package/build/code/save.js +3 -1
- package/build/code/save.js.map +1 -1
- package/build/image/edit.js +6 -3
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +11 -5
- package/build/image/image.js.map +1 -1
- package/build/list-item/edit.js +1 -3
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +0 -7
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/index.js +4 -1
- package/build/list-item/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +20 -19
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/site-logo/edit.js +7 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build-module/block/deprecated.js +71 -11
- package/build-module/block/deprecated.js.map +1 -1
- package/build-module/block/edit.js +66 -32
- package/build-module/block/edit.js.map +1 -1
- package/build-module/code/save.js +3 -1
- package/build-module/code/save.js.map +1 -1
- package/build-module/image/edit.js +7 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +11 -5
- package/build-module/image/image.js.map +1 -1
- package/build-module/list-item/edit.js +2 -4
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +0 -1
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/index.js +4 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +2 -2
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +20 -19
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/site-logo/edit.js +7 -2
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-style/common-rtl.css +1 -0
- package/build-style/common.css +1 -0
- package/package.json +13 -13
- package/src/block/deprecated.js +76 -11
- package/src/block/edit.js +100 -32
- package/src/block/index.php +21 -12
- package/src/code/save.js +7 -1
- package/src/image/edit.js +10 -3
- package/src/image/image.js +20 -16
- package/src/list-item/edit.js +1 -2
- package/src/list-item/hooks/index.js +0 -1
- package/src/list-item/index.js +3 -0
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/edit/navigation-menu-selector.js +34 -16
- package/src/navigation/edit/test/navigation-menu-selector.js +61 -39
- package/src/navigation/index.php +19 -13
- package/src/search/index.php +1 -1
- package/src/site-logo/edit.js +10 -5
- package/build/list-item/hooks/use-copy.js +0 -39
- package/build/list-item/hooks/use-copy.js.map +0 -1
- package/build-module/list-item/hooks/use-copy.js +0 -32
- package/build-module/list-item/hooks/use-copy.js.map +0 -1
- package/src/list-item/hooks/use-copy.js +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blob","_element","_i18n","_components","_compose","_blockEditor","_data","_coreData","_icons","_notices","_useClientWidth","_constants","ALLOWED_MEDIA_TYPES","ACCEPT_MEDIA_STRING","SiteLogo","alt","attributes","align","width","height","isLink","linkTarget","shouldSyncIcon","containerRef","isSelected","setAttributes","setLogo","logoUrl","siteUrl","logoId","iconId","setIcon","canUserEdit","clientWidth","useClientWidth","isLargeViewport","useViewportMatch","isWideAligned","includes","isResizable","naturalWidth","naturalHeight","setNaturalSize","useState","isEditingImage","setIsEditingImage","toggleSelection","useDispatch","blockEditorStore","classes","classnames","isBlobURL","imageEditing","maxWidth","title","useSelect","select","settings","getSettings","siteEntities","coreStore","getEntityRecord","name","useEffect","onResizeStart","onResizeStop","img","_react","createElement","className","src","onLoad","event","target","imgWrapper","href","rel","onClick","preventDefault","imageWidthWithinContainer","exceedMaxWidth","style","defaultWidth","currentWidth","ratio","currentHeight","minWidth","MIN_SIZE","Math","ceil","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","isRTL","canEditImage","imgEdit","__experimentalImageEditor","id","url","onSaveImage","imageAttributes","onFinishEditing","ResizableBox","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","delta","parseInt","syncSiteIconHelpText","createInterpolateElement","__","a","Fragment","InspectorControls","PanelBody","RangeControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","onChange","newWidth","min","max","initialPosition","value","disabled","ToggleControl","checked","undefined","help","BlockControls","group","ToolbarButton","icon","crop","SiteLogoReplaceFlow","onRemoveLogo","mediaReplaceProps","MediaReplaceFlow","allowedTypes","accept","MenuItem","InspectorLogoPreview","mediaItemData","itemGroupProps","alt_text","source_url","slug","logoSlug","media_details","logoMediaDetails","logoLabel","sizes","full","file","__experimentalItemGroup","as","__experimentalHStack","justify","FlexItem","__experimentalTruncate","numberOfLines","LogoEdit","ref","useRef","siteLogoId","siteIconId","isRequestingMediaItem","canUser","getEditedEntityRecord","_canUserEdit","siteSettings","siteData","_siteLogoId","site_logo","_siteIconId","site_icon","mediaItem","getMedia","context","_isRequestingMediaItem","hasFinishedResolution","home","editEntityRecord","newValue","shouldForceSync","onInitialSelectLogo","media","onSelectLogo","createErrorNotice","noticesStore","onUploadError","message","type","onFilesDrop","filesList","mediaUpload","onFileChange","image","onError","mediaReplaceFlowProps","mediaURL","onSelect","controls","logoImage","isLoading","Spinner","placeholder","content","placeholderClassName","Placeholder","preview","withIllustration","blockProps","useBlockProps","mediaInspectorPanel","isBordered","popoverProps","MediaUploadCheck","MediaUpload","render","open","Button","variant","DropZone","MediaPlaceholder","mediaLibraryButton","upload","showTooltip","tooltipPosition"],"sources":["@wordpress/block-library/src/site-logo/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tcreateInterpolateElement,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n} from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tMenuItem,\n\tPanelBody,\n\tRangeControl,\n\tResizableBox,\n\tSpinner,\n\tToggleControl,\n\tToolbarButton,\n\tPlaceholder,\n\tButton,\n\tDropZone,\n\tFlexItem,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalImageEditor as ImageEditor,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { crop, upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport useClientWidth from '../image/use-client-width';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE } from '../image/constants';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst ACCEPT_MEDIA_STRING = 'image/*';\n\nconst SiteLogo = ( {\n\talt,\n\tattributes: { align, width, height, isLink, linkTarget, shouldSyncIcon },\n\tcontainerRef,\n\tisSelected,\n\tsetAttributes,\n\tsetLogo,\n\tlogoUrl,\n\tsiteUrl,\n\tlogoId,\n\ticonId,\n\tsetIcon,\n\tcanUserEdit,\n} ) => {\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst isResizable = ! isWideAligned && isLargeViewport;\n\tconst [ { naturalWidth, naturalHeight }, setNaturalSize ] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst { toggleSelection } = useDispatch( blockEditorStore );\n\tconst classes = classnames( 'custom-logo-link', {\n\t\t'is-transient': isBlobURL( logoUrl ),\n\t} );\n\tconst { imageEditing, maxWidth, title } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\tconst siteEntities = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t);\n\t\treturn {\n\t\t\ttitle: siteEntities?.name,\n\t\t\timageEditing: settings.imageEditing,\n\t\t\tmaxWidth: settings.maxWidth,\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Turn the `Use as site icon` toggle off if it is on but the logo and icon have\n\t\t// fallen out of sync. This can happen if the toggle is saved in the `on` position,\n\t\t// but changes are later made to the site icon in the Customizer.\n\t\tif ( shouldSyncIcon && logoId !== iconId ) {\n\t\t\tsetAttributes( { shouldSyncIcon: false } );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tconst img = (\n\t\t<img\n\t\t\tclassName=\"custom-logo\"\n\t\t\tsrc={ logoUrl }\n\t\t\talt={ alt }\n\t\t\tonLoad={ ( event ) => {\n\t\t\t\tsetNaturalSize( {\n\t\t\t\t\tnaturalWidth: event.target.naturalWidth,\n\t\t\t\t\tnaturalHeight: event.target.naturalHeight,\n\t\t\t\t} );\n\t\t\t} }\n\t\t/>\n\t);\n\n\tlet imgWrapper = img;\n\n\t// Disable reason: Image itself is not meant to be interactive, but\n\t// should direct focus to block.\n\tif ( isLink ) {\n\t\timgWrapper = (\n\t\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t\t<a\n\t\t\t\thref={ siteUrl }\n\t\t\t\tclassName={ classes }\n\t\t\t\trel=\"home\"\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</a>\n\t\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t);\n\t}\n\n\tlet imageWidthWithinContainer;\n\n\tif ( clientWidth && naturalWidth && naturalHeight ) {\n\t\tconst exceedMaxWidth = naturalWidth > clientWidth;\n\t\timageWidthWithinContainer = exceedMaxWidth ? clientWidth : naturalWidth;\n\t}\n\n\tif ( ! isResizable || ! imageWidthWithinContainer ) {\n\t\treturn <div style={ { width, height } }>{ imgWrapper }</div>;\n\t}\n\n\t// Set the default width to a responsible size.\n\t// Note that this width is also set in the attached frontend CSS file.\n\tconst defaultWidth = 120;\n\n\tconst currentWidth = width || defaultWidth;\n\tconst ratio = naturalWidth / naturalHeight;\n\tconst currentHeight = currentWidth / ratio;\n\tconst minWidth =\n\t\tnaturalWidth < naturalHeight ? MIN_SIZE : Math.ceil( MIN_SIZE * ratio );\n\tconst minHeight =\n\t\tnaturalHeight < naturalWidth ? MIN_SIZE : Math.ceil( MIN_SIZE / ratio );\n\n\t// With the current implementation of ResizableBox, an image needs an\n\t// explicit pixel value for the max-width. In absence of being able to\n\t// set the content-width, this max-width is currently dictated by the\n\t// vanilla editor style. The following variable adds a buffer to this\n\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t// in most cases, allow you to scale the image beyond the width of the\n\t// main column, though not infinitely.\n\t// @todo It would be good to revisit this once a content-width variable\n\t// becomes available.\n\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\tlet showRightHandle = false;\n\tlet showLeftHandle = false;\n\n\t/* eslint-disable no-lonely-if */\n\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\tif ( align === 'center' ) {\n\t\t// When the image is centered, show both handles.\n\t\tshowRightHandle = true;\n\t\tshowLeftHandle = true;\n\t} else if ( isRTL() ) {\n\t\t// In RTL mode the image is on the right by default.\n\t\t// Show the right handle and hide the left handle only when it is\n\t\t// aligned left. Otherwise always show the left handle.\n\t\tif ( align === 'left' ) {\n\t\t\tshowRightHandle = true;\n\t\t} else {\n\t\t\tshowLeftHandle = true;\n\t\t}\n\t} else {\n\t\t// Show the left handle and hide the right handle only when the\n\t\t// image is aligned right. Otherwise always show the right handle.\n\t\tif ( align === 'right' ) {\n\t\t\tshowLeftHandle = true;\n\t\t} else {\n\t\t\tshowRightHandle = true;\n\t\t}\n\t}\n\t/* eslint-enable no-lonely-if */\n\n\tconst canEditImage =\n\t\tlogoId && naturalWidth && naturalHeight && imageEditing;\n\n\tconst imgEdit =\n\t\tcanEditImage && isEditingImage ? (\n\t\t\t<ImageEditor\n\t\t\t\tid={ logoId }\n\t\t\t\turl={ logoUrl }\n\t\t\t\twidth={ currentWidth }\n\t\t\t\theight={ currentHeight }\n\t\t\t\tclientWidth={ clientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) => {\n\t\t\t\t\tsetLogo( imageAttributes.id );\n\t\t\t\t} }\n\t\t\t\tonFinishEditing={ () => {\n\t\t\t\t\tsetIsEditingImage( false );\n\t\t\t\t} }\n\t\t\t/>\n\t\t) : (\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth,\n\t\t\t\t\theight: currentHeight,\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxWidthBuffer }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxWidthBuffer / ratio }\n\t\t\t\tlockAspectRatio\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( currentWidth + delta.width, 10 ),\n\t\t\t\t\t\theight: parseInt( currentHeight + delta.height, 10 ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ imgWrapper }\n\t\t\t</ResizableBox>\n\t\t);\n\n\tconst syncSiteIconHelpText = createInterpolateElement(\n\t\t__(\n\t\t\t'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. To use a custom icon that is different from your site logo, use the <a>Site Icon settings</a>.'\n\t\t),\n\t\t{\n\t\t\ta: (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t<a\n\t\t\t\t\thref={\n\t\t\t\t\t\tsiteUrl +\n\t\t\t\t\t\t'/wp-admin/customize.php?autofocus[section]=title_tagline'\n\t\t\t\t\t}\n\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t/>\n\t\t\t),\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Image width' ) }\n\t\t\t\t\t\tonChange={ ( newWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: newWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ minWidth }\n\t\t\t\t\t\tmax={ maxWidthBuffer }\n\t\t\t\t\t\tinitialPosition={ Math.min(\n\t\t\t\t\t\t\tdefaultWidth,\n\t\t\t\t\t\t\tmaxWidthBuffer\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ width || '' }\n\t\t\t\t\t\tdisabled={ ! isResizable }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Link image to home' ) }\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canUserEdit && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Use as site icon' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { shouldSyncIcon: value } );\n\t\t\t\t\t\t\t\t\tsetIcon( value ? logoId : undefined );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tchecked={ !! shouldSyncIcon }\n\t\t\t\t\t\t\t\thelp={ syncSiteIconHelpText }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ canEditImage && ! isEditingImage && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => setIsEditingImage( true ) }\n\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\tlabel={ __( 'Crop' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ imgEdit }\n\t\t</>\n\t);\n};\n\n// This is a light wrapper around MediaReplaceFlow because the block has two\n// different MediaReplaceFlows, one for the inspector and one for the toolbar.\nfunction SiteLogoReplaceFlow( { onRemoveLogo, ...mediaReplaceProps } ) {\n\treturn (\n\t\t<MediaReplaceFlow\n\t\t\t{ ...mediaReplaceProps }\n\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\taccept={ ACCEPT_MEDIA_STRING }\n\t\t>\n\t\t\t<MenuItem onClick={ onRemoveLogo }>{ __( 'Reset' ) }</MenuItem>\n\t\t</MediaReplaceFlow>\n\t);\n}\n\nconst InspectorLogoPreview = ( { mediaItemData = {}, itemGroupProps } ) => {\n\tconst {\n\t\talt_text: alt,\n\t\tsource_url: logoUrl,\n\t\tslug: logoSlug,\n\t\tmedia_details: logoMediaDetails,\n\t} = mediaItemData;\n\tconst logoLabel = logoMediaDetails?.sizes?.full?.file || logoSlug;\n\treturn (\n\t\t<ItemGroup { ...itemGroupProps } as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<img src={ logoUrl } alt={ alt } />\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-library-site-logo__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ logoLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n};\n\nexport default function LogoEdit( {\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tisSelected,\n} ) {\n\tconst { width, shouldSyncIcon } = attributes;\n\tconst ref = useRef();\n\n\tconst {\n\t\tsiteLogoId,\n\t\tcanUserEdit,\n\t\turl,\n\t\tsiteIconId,\n\t\tmediaItemData,\n\t\tisRequestingMediaItem,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst _canUserEdit = canUser( 'update', 'settings' );\n\t\tconst siteSettings = _canUserEdit\n\t\t\t? getEditedEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\t\tconst _siteLogoId = _canUserEdit\n\t\t\t? siteSettings?.site_logo\n\t\t\t: siteData?.site_logo;\n\t\tconst _siteIconId = siteSettings?.site_icon;\n\t\tconst mediaItem =\n\t\t\t_siteLogoId &&\n\t\t\tselect( coreStore ).getMedia( _siteLogoId, {\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\tconst _isRequestingMediaItem =\n\t\t\t_siteLogoId &&\n\t\t\t! select( coreStore ).hasFinishedResolution( 'getMedia', [\n\t\t\t\t_siteLogoId,\n\t\t\t\t{ context: 'view' },\n\t\t\t] );\n\n\t\treturn {\n\t\t\tsiteLogoId: _siteLogoId,\n\t\t\tcanUserEdit: _canUserEdit,\n\t\t\turl: siteData?.home,\n\t\t\tmediaItemData: mediaItem,\n\t\t\tisRequestingMediaItem: _isRequestingMediaItem,\n\t\t\tsiteIconId: _siteIconId,\n\t\t};\n\t}, [] );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst setLogo = ( newValue, shouldForceSync = false ) => {\n\t\t// `shouldForceSync` is used to force syncing when the attribute\n\t\t// may not have updated yet.\n\t\tif ( shouldSyncIcon || shouldForceSync ) {\n\t\t\tsetIcon( newValue );\n\t\t}\n\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tsite_logo: newValue,\n\t\t} );\n\t};\n\n\tconst setIcon = ( newValue ) =>\n\t\t// The new value needs to be `null` to reset the Site Icon.\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tsite_icon: newValue ?? null,\n\t\t} );\n\n\tconst { alt_text: alt, source_url: logoUrl } = mediaItemData ?? {};\n\n\tconst onInitialSelectLogo = ( media ) => {\n\t\t// Initialize the syncSiteIcon toggle. If we currently have no Site logo and no\n\t\t// site icon, automatically sync the logo to the icon.\n\t\tif ( shouldSyncIcon === undefined ) {\n\t\t\tconst shouldForceSync = ! siteIconId;\n\t\t\tsetAttributes( { shouldSyncIcon: shouldForceSync } );\n\n\t\t\t// Because we cannot rely on the `shouldSyncIcon` attribute to have updated by\n\t\t\t// the time `setLogo` is called, pass an argument to force the syncing.\n\t\t\tonSelectLogo( media, shouldForceSync );\n\t\t\treturn;\n\t\t}\n\n\t\tonSelectLogo( media );\n\t};\n\n\tconst onSelectLogo = ( media, shouldForceSync = false ) => {\n\t\tif ( ! media ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! media.id && media.url ) {\n\t\t\t// This is a temporary blob image.\n\t\t\tsetLogo( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\tsetLogo( media.id, shouldForceSync );\n\t};\n\n\tconst onRemoveLogo = () => {\n\t\tsetLogo( null );\n\t\tsetAttributes( { width: undefined } );\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonInitialSelectLogo( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst mediaReplaceFlowProps = {\n\t\tmediaURL: logoUrl,\n\t\tonSelect: onSelectLogo,\n\t\tonError: onUploadError,\n\t\tonRemoveLogo,\n\t};\n\tconst controls = canUserEdit && logoUrl && (\n\t\t<BlockControls group=\"other\">\n\t\t\t<SiteLogoReplaceFlow { ...mediaReplaceFlowProps } />\n\t\t</BlockControls>\n\t);\n\n\tlet logoImage;\n\tconst isLoading = siteLogoId === undefined || isRequestingMediaItem;\n\tif ( isLoading ) {\n\t\tlogoImage = <Spinner />;\n\t}\n\tif ( !! logoUrl ) {\n\t\tlogoImage = (\n\t\t\t<SiteLogo\n\t\t\t\talt={ alt }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tclassName={ className }\n\t\t\t\tcontainerRef={ ref }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tlogoUrl={ logoUrl }\n\t\t\t\tsetLogo={ setLogo }\n\t\t\t\tlogoId={ mediaItemData?.id || siteLogoId }\n\t\t\t\tsiteUrl={ url }\n\t\t\t\tsetIcon={ setIcon }\n\t\t\t\ticonId={ siteIconId }\n\t\t\t\tcanUserEdit={ canUserEdit }\n\t\t\t/>\n\t\t);\n\t}\n\tconst placeholder = ( content ) => {\n\t\tconst placeholderClassName = classnames(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tpreview={ logoImage }\n\t\t\t\twithIllustration={ true }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = classnames( className, {\n\t\t'is-default-size': ! width,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\tconst label = __( 'Add a site logo' );\n\n\tconst mediaInspectorPanel = ( canUserEdit || logoUrl ) && (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Media' ) }>\n\t\t\t\t<div className=\"block-library-site-logo__inspector-media-replace-container\">\n\t\t\t\t\t{ ! canUserEdit && !! logoUrl && (\n\t\t\t\t\t\t<InspectorLogoPreview\n\t\t\t\t\t\t\tmediaItemData={ mediaItemData }\n\t\t\t\t\t\t\titemGroupProps={ {\n\t\t\t\t\t\t\t\tisBordered: true,\n\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t'block-library-site-logo__inspector-readonly-logo-preview',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canUserEdit && !! logoUrl && (\n\t\t\t\t\t\t<SiteLogoReplaceFlow\n\t\t\t\t\t\t\t{ ...mediaReplaceFlowProps }\n\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t<InspectorLogoPreview\n\t\t\t\t\t\t\t\t\tmediaItemData={ mediaItemData }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpopoverProps={ {} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canUserEdit && ! logoUrl && (\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\tonSelect={ onInitialSelectLogo }\n\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<div className=\"block-library-site-logo__inspector-upload-container\">\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ isLoading ? (\n\t\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'Add media' )\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onFilesDrop } />\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ controls }\n\t\t\t{ mediaInspectorPanel }\n\t\t\t{ !! logoUrl && logoImage }\n\t\t\t{ ! logoUrl && ! canUserEdit && (\n\t\t\t\t<Placeholder className=\"site-logo_placeholder\">\n\t\t\t\t\t{ !! isLoading && (\n\t\t\t\t\t\t<span className=\"components-placeholder__preview\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! logoUrl && canUserEdit && (\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\tonSelect={ onInitialSelectLogo }\n\t\t\t\t\taccept={ ACCEPT_MEDIA_STRING }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAG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AA,EAACjE,WAAA,CAAAsO,QAAQ;MAAC9B,WAAW,EAAGA;IAAa,CAAE,CACnC;EACH,CACH,CACgB,CAEf,CACK,CACO,CACnB;EAED,OACC,IAAAxI,MAAA,CAAAC,aAAA;IAAA,GAAU0J;EAAU,GACjBV,QAAQ,EACRY,mBAAmB,EACnB,CAAC,CAAErM,OAAO,IAAI0L,SAAS,EACvB,CAAE1L,OAAO,IAAI,CAAEK,WAAW,IAC3B,IAAAmC,MAAA,CAAAC,aAAA,EAACjE,WAAA,CAAAwN,WAAW;IAACtJ,SAAS,EAAC;EAAuB,GAC3C,CAAC,CAAEiJ,SAAS,IACb,IAAAnJ,MAAA,CAAAC,aAAA;IAAMC,SAAS,EAAC;EAAiC,GAChD,IAAAF,MAAA,CAAAC,aAAA,EAACjE,WAAA,CAAAoN,OAAO,MAAE,CACL,CAEK,CACb,EACC,CAAE5L,OAAO,IAAIK,WAAW,IACzB,IAAAmC,MAAA,CAAAC,aAAA,EAAC/D,YAAA,CAAAqO,gBAAgB;IAChBvB,QAAQ,EAAGhB,mBAAqB;IAChC9C,MAAM,EAAGxI,mBAAqB;IAC9BuI,YAAY,EAAGxI,mBAAqB;IACpCoM,OAAO,EAAGR,aAAe;IACzBgB,WAAW,EAAGA,WAAa;IAC3BmB,kBAAkB,EAAGA,CAAE;MAAEL;IAAK,CAAC,KAAM;MACpC,OACC,IAAAnK,MAAA,CAAAC,aAAA,EAACjE,WAAA,CAAAoO,MAAM;QACNzF,IAAI,EAAG8F,aAAQ;QACfJ,OAAO,EAAC,SAAS;QACjBzG,KAAK,EAAGA,KAAO;QACf8G,WAAW;QACXC,eAAe,EAAC,YAAY;QAC5BjK,OAAO,EAAGA,CAAA,KAAM;UACfyJ,IAAI,CAAC,CAAC;QACP;MAAG,CACH,CAAC;IAEJ;EAAG,CACH,CAEE,CAAC;AAER"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blob","_element","_i18n","_components","_compose","_blockEditor","_data","_coreData","_icons","_notices","_useClientWidth","_constants","ALLOWED_MEDIA_TYPES","ACCEPT_MEDIA_STRING","SiteLogo","alt","attributes","align","width","height","isLink","linkTarget","shouldSyncIcon","containerRef","isSelected","setAttributes","setLogo","logoUrl","siteUrl","logoId","iconId","setIcon","canUserEdit","clientWidth","useClientWidth","isLargeViewport","useViewportMatch","isWideAligned","includes","isResizable","naturalWidth","naturalHeight","setNaturalSize","useState","isEditingImage","setIsEditingImage","toggleSelection","useDispatch","blockEditorStore","classes","classnames","isBlobURL","imageEditing","maxWidth","title","useSelect","select","settings","getSettings","siteEntities","coreStore","getEntityRecord","name","useEffect","onResizeStart","onResizeStop","img","_react","createElement","className","src","onLoad","event","target","imgWrapper","href","rel","onClick","preventDefault","imageWidthWithinContainer","exceedMaxWidth","style","defaultWidth","currentWidth","ratio","currentHeight","minWidth","MIN_SIZE","Math","ceil","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","isRTL","canEditImage","imgEdit","__experimentalImageEditor","id","url","onSaveImage","imageAttributes","onFinishEditing","ResizableBox","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","delta","parseInt","shouldUseNewUrl","window","__experimentalUseCustomizerSiteLogoUrl","siteIconSettingsUrl","syncSiteIconHelpText","createInterpolateElement","__","a","Fragment","InspectorControls","PanelBody","RangeControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","onChange","newWidth","min","max","initialPosition","value","disabled","ToggleControl","checked","undefined","help","BlockControls","group","ToolbarButton","icon","crop","SiteLogoReplaceFlow","onRemoveLogo","mediaReplaceProps","MediaReplaceFlow","allowedTypes","accept","MenuItem","InspectorLogoPreview","mediaItemData","itemGroupProps","alt_text","source_url","slug","logoSlug","media_details","logoMediaDetails","logoLabel","sizes","full","file","__experimentalItemGroup","as","__experimentalHStack","justify","FlexItem","__experimentalTruncate","numberOfLines","LogoEdit","ref","useRef","siteLogoId","siteIconId","isRequestingMediaItem","canUser","getEditedEntityRecord","_canUserEdit","siteSettings","siteData","_siteLogoId","site_logo","_siteIconId","site_icon","mediaItem","getMedia","context","_isRequestingMediaItem","hasFinishedResolution","home","editEntityRecord","newValue","shouldForceSync","onInitialSelectLogo","media","onSelectLogo","createErrorNotice","noticesStore","onUploadError","message","type","onFilesDrop","filesList","mediaUpload","onFileChange","image","onError","mediaReplaceFlowProps","mediaURL","onSelect","controls","logoImage","isLoading","Spinner","placeholder","content","placeholderClassName","Placeholder","preview","withIllustration","blockProps","useBlockProps","mediaInspectorPanel","isBordered","popoverProps","MediaUploadCheck","MediaUpload","render","open","Button","variant","DropZone","MediaPlaceholder","mediaLibraryButton","upload","showTooltip","tooltipPosition"],"sources":["@wordpress/block-library/src/site-logo/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tcreateInterpolateElement,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n} from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tMenuItem,\n\tPanelBody,\n\tRangeControl,\n\tResizableBox,\n\tSpinner,\n\tToggleControl,\n\tToolbarButton,\n\tPlaceholder,\n\tButton,\n\tDropZone,\n\tFlexItem,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalImageEditor as ImageEditor,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { crop, upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport useClientWidth from '../image/use-client-width';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE } from '../image/constants';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst ACCEPT_MEDIA_STRING = 'image/*';\n\nconst SiteLogo = ( {\n\talt,\n\tattributes: { align, width, height, isLink, linkTarget, shouldSyncIcon },\n\tcontainerRef,\n\tisSelected,\n\tsetAttributes,\n\tsetLogo,\n\tlogoUrl,\n\tsiteUrl,\n\tlogoId,\n\ticonId,\n\tsetIcon,\n\tcanUserEdit,\n} ) => {\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst isResizable = ! isWideAligned && isLargeViewport;\n\tconst [ { naturalWidth, naturalHeight }, setNaturalSize ] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst { toggleSelection } = useDispatch( blockEditorStore );\n\tconst classes = classnames( 'custom-logo-link', {\n\t\t'is-transient': isBlobURL( logoUrl ),\n\t} );\n\tconst { imageEditing, maxWidth, title } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\tconst siteEntities = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t);\n\t\treturn {\n\t\t\ttitle: siteEntities?.name,\n\t\t\timageEditing: settings.imageEditing,\n\t\t\tmaxWidth: settings.maxWidth,\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Turn the `Use as site icon` toggle off if it is on but the logo and icon have\n\t\t// fallen out of sync. This can happen if the toggle is saved in the `on` position,\n\t\t// but changes are later made to the site icon in the Customizer.\n\t\tif ( shouldSyncIcon && logoId !== iconId ) {\n\t\t\tsetAttributes( { shouldSyncIcon: false } );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tconst img = (\n\t\t<img\n\t\t\tclassName=\"custom-logo\"\n\t\t\tsrc={ logoUrl }\n\t\t\talt={ alt }\n\t\t\tonLoad={ ( event ) => {\n\t\t\t\tsetNaturalSize( {\n\t\t\t\t\tnaturalWidth: event.target.naturalWidth,\n\t\t\t\t\tnaturalHeight: event.target.naturalHeight,\n\t\t\t\t} );\n\t\t\t} }\n\t\t/>\n\t);\n\n\tlet imgWrapper = img;\n\n\t// Disable reason: Image itself is not meant to be interactive, but\n\t// should direct focus to block.\n\tif ( isLink ) {\n\t\timgWrapper = (\n\t\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t\t<a\n\t\t\t\thref={ siteUrl }\n\t\t\t\tclassName={ classes }\n\t\t\t\trel=\"home\"\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</a>\n\t\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t);\n\t}\n\n\tlet imageWidthWithinContainer;\n\n\tif ( clientWidth && naturalWidth && naturalHeight ) {\n\t\tconst exceedMaxWidth = naturalWidth > clientWidth;\n\t\timageWidthWithinContainer = exceedMaxWidth ? clientWidth : naturalWidth;\n\t}\n\n\tif ( ! isResizable || ! imageWidthWithinContainer ) {\n\t\treturn <div style={ { width, height } }>{ imgWrapper }</div>;\n\t}\n\n\t// Set the default width to a responsible size.\n\t// Note that this width is also set in the attached frontend CSS file.\n\tconst defaultWidth = 120;\n\n\tconst currentWidth = width || defaultWidth;\n\tconst ratio = naturalWidth / naturalHeight;\n\tconst currentHeight = currentWidth / ratio;\n\tconst minWidth =\n\t\tnaturalWidth < naturalHeight ? MIN_SIZE : Math.ceil( MIN_SIZE * ratio );\n\tconst minHeight =\n\t\tnaturalHeight < naturalWidth ? MIN_SIZE : Math.ceil( MIN_SIZE / ratio );\n\n\t// With the current implementation of ResizableBox, an image needs an\n\t// explicit pixel value for the max-width. In absence of being able to\n\t// set the content-width, this max-width is currently dictated by the\n\t// vanilla editor style. The following variable adds a buffer to this\n\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t// in most cases, allow you to scale the image beyond the width of the\n\t// main column, though not infinitely.\n\t// @todo It would be good to revisit this once a content-width variable\n\t// becomes available.\n\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\tlet showRightHandle = false;\n\tlet showLeftHandle = false;\n\n\t/* eslint-disable no-lonely-if */\n\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\tif ( align === 'center' ) {\n\t\t// When the image is centered, show both handles.\n\t\tshowRightHandle = true;\n\t\tshowLeftHandle = true;\n\t} else if ( isRTL() ) {\n\t\t// In RTL mode the image is on the right by default.\n\t\t// Show the right handle and hide the left handle only when it is\n\t\t// aligned left. Otherwise always show the left handle.\n\t\tif ( align === 'left' ) {\n\t\t\tshowRightHandle = true;\n\t\t} else {\n\t\t\tshowLeftHandle = true;\n\t\t}\n\t} else {\n\t\t// Show the left handle and hide the right handle only when the\n\t\t// image is aligned right. Otherwise always show the right handle.\n\t\tif ( align === 'right' ) {\n\t\t\tshowLeftHandle = true;\n\t\t} else {\n\t\t\tshowRightHandle = true;\n\t\t}\n\t}\n\t/* eslint-enable no-lonely-if */\n\n\tconst canEditImage =\n\t\tlogoId && naturalWidth && naturalHeight && imageEditing;\n\n\tconst imgEdit =\n\t\tcanEditImage && isEditingImage ? (\n\t\t\t<ImageEditor\n\t\t\t\tid={ logoId }\n\t\t\t\turl={ logoUrl }\n\t\t\t\twidth={ currentWidth }\n\t\t\t\theight={ currentHeight }\n\t\t\t\tclientWidth={ clientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) => {\n\t\t\t\t\tsetLogo( imageAttributes.id );\n\t\t\t\t} }\n\t\t\t\tonFinishEditing={ () => {\n\t\t\t\t\tsetIsEditingImage( false );\n\t\t\t\t} }\n\t\t\t/>\n\t\t) : (\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth,\n\t\t\t\t\theight: currentHeight,\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxWidthBuffer }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxWidthBuffer / ratio }\n\t\t\t\tlockAspectRatio\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( currentWidth + delta.width, 10 ),\n\t\t\t\t\t\theight: parseInt( currentHeight + delta.height, 10 ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ imgWrapper }\n\t\t\t</ResizableBox>\n\t\t);\n\n\t// Support the previous location for the Site Icon settings. To be removed\n\t// when the required WP core version for Gutenberg is >= 6.5.0.\n\tconst shouldUseNewUrl = ! window?.__experimentalUseCustomizerSiteLogoUrl;\n\n\tconst siteIconSettingsUrl = shouldUseNewUrl\n\t\t? siteUrl + '/wp-admin/options-general.php'\n\t\t: siteUrl + '/wp-admin/customize.php?autofocus[section]=title_tagline';\n\n\tconst syncSiteIconHelpText = createInterpolateElement(\n\t\t__(\n\t\t\t'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. To use a custom icon that is different from your site logo, use the <a>Site Icon settings</a>.'\n\t\t),\n\t\t{\n\t\t\ta: (\n\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t<a\n\t\t\t\t\thref={ siteIconSettingsUrl }\n\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t/>\n\t\t\t),\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Image width' ) }\n\t\t\t\t\t\tonChange={ ( newWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: newWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ minWidth }\n\t\t\t\t\t\tmax={ maxWidthBuffer }\n\t\t\t\t\t\tinitialPosition={ Math.min(\n\t\t\t\t\t\t\tdefaultWidth,\n\t\t\t\t\t\t\tmaxWidthBuffer\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ width || '' }\n\t\t\t\t\t\tdisabled={ ! isResizable }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Link image to home' ) }\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canUserEdit && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Use as Site Icon' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { shouldSyncIcon: value } );\n\t\t\t\t\t\t\t\t\tsetIcon( value ? logoId : undefined );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tchecked={ !! shouldSyncIcon }\n\t\t\t\t\t\t\t\thelp={ syncSiteIconHelpText }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ canEditImage && ! isEditingImage && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => setIsEditingImage( true ) }\n\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\tlabel={ __( 'Crop' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ imgEdit }\n\t\t</>\n\t);\n};\n\n// This is a light wrapper around MediaReplaceFlow because the block has two\n// different MediaReplaceFlows, one for the inspector and one for the toolbar.\nfunction SiteLogoReplaceFlow( { onRemoveLogo, ...mediaReplaceProps } ) {\n\treturn (\n\t\t<MediaReplaceFlow\n\t\t\t{ ...mediaReplaceProps }\n\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\taccept={ ACCEPT_MEDIA_STRING }\n\t\t>\n\t\t\t<MenuItem onClick={ onRemoveLogo }>{ __( 'Reset' ) }</MenuItem>\n\t\t</MediaReplaceFlow>\n\t);\n}\n\nconst InspectorLogoPreview = ( { mediaItemData = {}, itemGroupProps } ) => {\n\tconst {\n\t\talt_text: alt,\n\t\tsource_url: logoUrl,\n\t\tslug: logoSlug,\n\t\tmedia_details: logoMediaDetails,\n\t} = mediaItemData;\n\tconst logoLabel = logoMediaDetails?.sizes?.full?.file || logoSlug;\n\treturn (\n\t\t<ItemGroup { ...itemGroupProps } as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<img src={ logoUrl } alt={ alt } />\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-library-site-logo__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ logoLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n};\n\nexport default function LogoEdit( {\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tisSelected,\n} ) {\n\tconst { width, shouldSyncIcon } = attributes;\n\tconst ref = useRef();\n\n\tconst {\n\t\tsiteLogoId,\n\t\tcanUserEdit,\n\t\turl,\n\t\tsiteIconId,\n\t\tmediaItemData,\n\t\tisRequestingMediaItem,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst _canUserEdit = canUser( 'update', 'settings' );\n\t\tconst siteSettings = _canUserEdit\n\t\t\t? getEditedEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\t\tconst _siteLogoId = _canUserEdit\n\t\t\t? siteSettings?.site_logo\n\t\t\t: siteData?.site_logo;\n\t\tconst _siteIconId = siteSettings?.site_icon;\n\t\tconst mediaItem =\n\t\t\t_siteLogoId &&\n\t\t\tselect( coreStore ).getMedia( _siteLogoId, {\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\tconst _isRequestingMediaItem =\n\t\t\t_siteLogoId &&\n\t\t\t! select( coreStore ).hasFinishedResolution( 'getMedia', [\n\t\t\t\t_siteLogoId,\n\t\t\t\t{ context: 'view' },\n\t\t\t] );\n\n\t\treturn {\n\t\t\tsiteLogoId: _siteLogoId,\n\t\t\tcanUserEdit: _canUserEdit,\n\t\t\turl: siteData?.home,\n\t\t\tmediaItemData: mediaItem,\n\t\t\tisRequestingMediaItem: _isRequestingMediaItem,\n\t\t\tsiteIconId: _siteIconId,\n\t\t};\n\t}, [] );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst setLogo = ( newValue, shouldForceSync = false ) => {\n\t\t// `shouldForceSync` is used to force syncing when the attribute\n\t\t// may not have updated yet.\n\t\tif ( shouldSyncIcon || shouldForceSync ) {\n\t\t\tsetIcon( newValue );\n\t\t}\n\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tsite_logo: newValue,\n\t\t} );\n\t};\n\n\tconst setIcon = ( newValue ) =>\n\t\t// The new value needs to be `null` to reset the Site Icon.\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tsite_icon: newValue ?? null,\n\t\t} );\n\n\tconst { alt_text: alt, source_url: logoUrl } = mediaItemData ?? {};\n\n\tconst onInitialSelectLogo = ( media ) => {\n\t\t// Initialize the syncSiteIcon toggle. If we currently have no Site logo and no\n\t\t// site icon, automatically sync the logo to the icon.\n\t\tif ( shouldSyncIcon === undefined ) {\n\t\t\tconst shouldForceSync = ! siteIconId;\n\t\t\tsetAttributes( { shouldSyncIcon: shouldForceSync } );\n\n\t\t\t// Because we cannot rely on the `shouldSyncIcon` attribute to have updated by\n\t\t\t// the time `setLogo` is called, pass an argument to force the syncing.\n\t\t\tonSelectLogo( media, shouldForceSync );\n\t\t\treturn;\n\t\t}\n\n\t\tonSelectLogo( media );\n\t};\n\n\tconst onSelectLogo = ( media, shouldForceSync = false ) => {\n\t\tif ( ! media ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! media.id && media.url ) {\n\t\t\t// This is a temporary blob image.\n\t\t\tsetLogo( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\tsetLogo( media.id, shouldForceSync );\n\t};\n\n\tconst onRemoveLogo = () => {\n\t\tsetLogo( null );\n\t\tsetAttributes( { width: undefined } );\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonInitialSelectLogo( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst mediaReplaceFlowProps = {\n\t\tmediaURL: logoUrl,\n\t\tonSelect: onSelectLogo,\n\t\tonError: onUploadError,\n\t\tonRemoveLogo,\n\t};\n\tconst controls = canUserEdit && logoUrl && (\n\t\t<BlockControls group=\"other\">\n\t\t\t<SiteLogoReplaceFlow { ...mediaReplaceFlowProps } />\n\t\t</BlockControls>\n\t);\n\n\tlet logoImage;\n\tconst isLoading = siteLogoId === undefined || isRequestingMediaItem;\n\tif ( isLoading ) {\n\t\tlogoImage = <Spinner />;\n\t}\n\tif ( !! logoUrl ) {\n\t\tlogoImage = (\n\t\t\t<SiteLogo\n\t\t\t\talt={ alt }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tclassName={ className }\n\t\t\t\tcontainerRef={ ref }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tlogoUrl={ logoUrl }\n\t\t\t\tsetLogo={ setLogo }\n\t\t\t\tlogoId={ mediaItemData?.id || siteLogoId }\n\t\t\t\tsiteUrl={ url }\n\t\t\t\tsetIcon={ setIcon }\n\t\t\t\ticonId={ siteIconId }\n\t\t\t\tcanUserEdit={ canUserEdit }\n\t\t\t/>\n\t\t);\n\t}\n\tconst placeholder = ( content ) => {\n\t\tconst placeholderClassName = classnames(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tpreview={ logoImage }\n\t\t\t\twithIllustration={ true }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = classnames( className, {\n\t\t'is-default-size': ! width,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref,\n\t\tclassName: classes,\n\t} );\n\n\tconst label = __( 'Add a site logo' );\n\n\tconst mediaInspectorPanel = ( canUserEdit || logoUrl ) && (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Media' ) }>\n\t\t\t\t<div className=\"block-library-site-logo__inspector-media-replace-container\">\n\t\t\t\t\t{ ! canUserEdit && !! logoUrl && (\n\t\t\t\t\t\t<InspectorLogoPreview\n\t\t\t\t\t\t\tmediaItemData={ mediaItemData }\n\t\t\t\t\t\t\titemGroupProps={ {\n\t\t\t\t\t\t\t\tisBordered: true,\n\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t'block-library-site-logo__inspector-readonly-logo-preview',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canUserEdit && !! logoUrl && (\n\t\t\t\t\t\t<SiteLogoReplaceFlow\n\t\t\t\t\t\t\t{ ...mediaReplaceFlowProps }\n\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t<InspectorLogoPreview\n\t\t\t\t\t\t\t\t\tmediaItemData={ mediaItemData }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpopoverProps={ {} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canUserEdit && ! logoUrl && (\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\tonSelect={ onInitialSelectLogo }\n\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<div className=\"block-library-site-logo__inspector-upload-container\">\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ isLoading ? (\n\t\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'Add media' )\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onFilesDrop } />\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ controls }\n\t\t\t{ mediaInspectorPanel }\n\t\t\t{ !! logoUrl && logoImage }\n\t\t\t{ ! logoUrl && ! canUserEdit && (\n\t\t\t\t<Placeholder className=\"site-logo_placeholder\">\n\t\t\t\t\t{ !! isLoading && (\n\t\t\t\t\t\t<span className=\"components-placeholder__preview\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! logoUrl && canUserEdit && (\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\tonSelect={ onInitialSelectLogo }\n\t\t\t\t\taccept={ ACCEPT_MEDIA_STRING }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAgBA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAWA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAKA,IAAAW,eAAA,GAAAZ,sBAAA,CAAAC,OAAA;AAKA,IAAAY,UAAA,GAAAZ,OAAA;AAzDA;AACA;AACA;;AAGA;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jE,WAAA,CAAA4N,WAAW;IAAC1J,SAAS,EAAC;EAAuB,GAC3C,CAAC,CAAEqJ,SAAS,IACb,IAAAvJ,MAAA,CAAAC,aAAA;IAAMC,SAAS,EAAC;EAAiC,GAChD,IAAAF,MAAA,CAAAC,aAAA,EAACjE,WAAA,CAAAwN,OAAO,MAAE,CACL,CAEK,CACb,EACC,CAAEhM,OAAO,IAAIK,WAAW,IACzB,IAAAmC,MAAA,CAAAC,aAAA,EAAC/D,YAAA,CAAAyO,gBAAgB;IAChBvB,QAAQ,EAAGhB,mBAAqB;IAChC9C,MAAM,EAAG5I,mBAAqB;IAC9B2I,YAAY,EAAG5I,mBAAqB;IACpCwM,OAAO,EAAGR,aAAe;IACzBgB,WAAW,EAAGA,WAAa;IAC3BmB,kBAAkB,EAAGA,CAAE;MAAEL;IAAK,CAAC,KAAM;MACpC,OACC,IAAAvK,MAAA,CAAAC,aAAA,EAACjE,WAAA,CAAAwO,MAAM;QACNzF,IAAI,EAAG8F,aAAQ;QACfJ,OAAO,EAAC,SAAS;QACjBzG,KAAK,EAAGA,KAAO;QACf8G,WAAW;QACXC,eAAe,EAAC,YAAY;QAC5BrK,OAAO,EAAGA,CAAA,KAAM;UACf6J,IAAI,CAAC,CAAC;QACP;MAAG,CACH,CAAC;IAEJ;EAAG,CACH,CAEE,CAAC;AAER"}
|
|
@@ -1,4 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
const isObject = obj => typeof obj === 'object' && !Array.isArray(obj) && obj !== null;
|
|
2
|
+
|
|
3
|
+
// v2: Migrate to a more condensed version of the 'content' attribute attribute.
|
|
4
|
+
const v2 = {
|
|
5
|
+
attributes: {
|
|
6
|
+
ref: {
|
|
7
|
+
type: 'number'
|
|
8
|
+
},
|
|
9
|
+
content: {
|
|
10
|
+
type: 'object'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
supports: {
|
|
14
|
+
customClassName: false,
|
|
15
|
+
html: false,
|
|
16
|
+
inserter: false,
|
|
17
|
+
renaming: false
|
|
18
|
+
},
|
|
19
|
+
// Force this deprecation to run whenever there's a values sub-property that's an object.
|
|
20
|
+
//
|
|
21
|
+
// This could fail in the future if a block ever has binding to a `values` attribute.
|
|
22
|
+
// Some extra protection is added to ensure `values` is an object, but this only reduces
|
|
23
|
+
// the likelihood, it doesn't solve it completely.
|
|
24
|
+
isEligible({
|
|
25
|
+
content
|
|
26
|
+
}) {
|
|
27
|
+
return !!content && Object.keys(content).every(contentKey => content[contentKey].values && isObject(content[contentKey].values));
|
|
28
|
+
},
|
|
29
|
+
/*
|
|
30
|
+
* Old attribute format:
|
|
31
|
+
* content: {
|
|
32
|
+
* "V98q_x": {
|
|
33
|
+
* // The attribute values are now stored as a 'values' sub-property.
|
|
34
|
+
* values: { content: 'My content value' },
|
|
35
|
+
* // ... additional metadata, like the block name can be stored here.
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* New attribute format:
|
|
40
|
+
* content: {
|
|
41
|
+
* "V98q_x": {
|
|
42
|
+
* content: 'My content value',
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
migrate(attributes) {
|
|
47
|
+
const {
|
|
48
|
+
content,
|
|
49
|
+
...retainedAttributes
|
|
50
|
+
} = attributes;
|
|
51
|
+
if (content && Object.keys(content).length) {
|
|
52
|
+
const updatedContent = {
|
|
53
|
+
...content
|
|
54
|
+
};
|
|
55
|
+
for (const contentKey in content) {
|
|
56
|
+
updatedContent[contentKey] = content[contentKey].values;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
...retainedAttributes,
|
|
60
|
+
content: updatedContent
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return attributes;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// v1: Rename the `overrides` attribute to the `content` attribute.
|
|
2
68
|
const v1 = {
|
|
3
69
|
attributes: {
|
|
4
70
|
ref: {
|
|
@@ -25,16 +91,12 @@ const v1 = {
|
|
|
25
91
|
* overrides: {
|
|
26
92
|
* // An key is an id that represents a block.
|
|
27
93
|
* // The values are the attribute values of the block.
|
|
28
|
-
* "V98q_x": { content: '
|
|
94
|
+
* "V98q_x": { content: 'My content value' }
|
|
29
95
|
* }
|
|
30
96
|
*
|
|
31
97
|
* New attribute format:
|
|
32
98
|
* content: {
|
|
33
|
-
* "V98q_x": {
|
|
34
|
-
* // The attribute values are now stored as a 'values' sub-property.
|
|
35
|
-
* values: { content: 'dwefwefwefwe' },
|
|
36
|
-
* // ... additional metadata, like the block name can be stored here.
|
|
37
|
-
* }
|
|
99
|
+
* "V98q_x": { content: 'My content value' }
|
|
38
100
|
* }
|
|
39
101
|
*
|
|
40
102
|
*/
|
|
@@ -45,9 +107,7 @@ const v1 = {
|
|
|
45
107
|
} = attributes;
|
|
46
108
|
const content = {};
|
|
47
109
|
Object.keys(overrides).forEach(id => {
|
|
48
|
-
content[id] =
|
|
49
|
-
values: overrides[id]
|
|
50
|
-
};
|
|
110
|
+
content[id] = overrides[id];
|
|
51
111
|
});
|
|
52
112
|
return {
|
|
53
113
|
...retainedAttributes,
|
|
@@ -55,5 +115,5 @@ const v1 = {
|
|
|
55
115
|
};
|
|
56
116
|
}
|
|
57
117
|
};
|
|
58
|
-
export default [v1];
|
|
118
|
+
export default [v2, v1];
|
|
59
119
|
//# sourceMappingURL=deprecated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isObject","obj","Array","isArray","v2","attributes","ref","type","content","supports","customClassName","html","inserter","renaming","isEligible","Object","keys","every","contentKey","values","migrate","retainedAttributes","length","updatedContent","v1","overrides","forEach","id"],"sources":["@wordpress/block-library/src/block/deprecated.js"],"sourcesContent":["const isObject = ( obj ) =>\n\ttypeof obj === 'object' && ! Array.isArray( obj ) && obj !== null;\n\n// v2: Migrate to a more condensed version of the 'content' attribute attribute.\nconst v2 = {\n\tattributes: {\n\t\tref: {\n\t\t\ttype: 'number',\n\t\t},\n\t\tcontent: {\n\t\t\ttype: 'object',\n\t\t},\n\t},\n\tsupports: {\n\t\tcustomClassName: false,\n\t\thtml: false,\n\t\tinserter: false,\n\t\trenaming: false,\n\t},\n\t// Force this deprecation to run whenever there's a values sub-property that's an object.\n\t//\n\t// This could fail in the future if a block ever has binding to a `values` attribute.\n\t// Some extra protection is added to ensure `values` is an object, but this only reduces\n\t// the likelihood, it doesn't solve it completely.\n\tisEligible( { content } ) {\n\t\treturn (\n\t\t\t!! content &&\n\t\t\tObject.keys( content ).every(\n\t\t\t\t( contentKey ) =>\n\t\t\t\t\tcontent[ contentKey ].values &&\n\t\t\t\t\tisObject( content[ contentKey ].values )\n\t\t\t)\n\t\t);\n\t},\n\t/*\n\t * Old attribute format:\n\t * content: {\n\t * \"V98q_x\": {\n\t * \t \t\t// The attribute values are now stored as a 'values' sub-property.\n\t * values: { content: 'My content value' },\n\t * \t // ... additional metadata, like the block name can be stored here.\n\t * }\n\t * }\n\t *\n\t * New attribute format:\n\t * content: {\n\t * \"V98q_x\": {\n\t * content: 'My content value',\n\t * }\n\t * }\n\t */\n\tmigrate( attributes ) {\n\t\tconst { content, ...retainedAttributes } = attributes;\n\n\t\tif ( content && Object.keys( content ).length ) {\n\t\t\tconst updatedContent = { ...content };\n\n\t\t\tfor ( const contentKey in content ) {\n\t\t\t\tupdatedContent[ contentKey ] = content[ contentKey ].values;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...retainedAttributes,\n\t\t\t\tcontent: updatedContent,\n\t\t\t};\n\t\t}\n\n\t\treturn attributes;\n\t},\n};\n\n// v1: Rename the `overrides` attribute to the `content` attribute.\nconst v1 = {\n\tattributes: {\n\t\tref: {\n\t\t\ttype: 'number',\n\t\t},\n\t\toverrides: {\n\t\t\ttype: 'object',\n\t\t},\n\t},\n\tsupports: {\n\t\tcustomClassName: false,\n\t\thtml: false,\n\t\tinserter: false,\n\t\trenaming: false,\n\t},\n\t// Force this deprecation to run whenever there's an `overrides` object.\n\tisEligible( { overrides } ) {\n\t\treturn !! overrides;\n\t},\n\t/*\n\t * Old attribute format:\n\t * overrides: {\n\t * // An key is an id that represents a block.\n\t * // The values are the attribute values of the block.\n\t * \"V98q_x\": { content: 'My content value' }\n\t * }\n\t *\n\t * New attribute format:\n\t * content: {\n\t * \"V98q_x\": { content: 'My content value' }\n\t * }\n\t *\n\t */\n\tmigrate( attributes ) {\n\t\tconst { overrides, ...retainedAttributes } = attributes;\n\n\t\tconst content = {};\n\n\t\tObject.keys( overrides ).forEach( ( id ) => {\n\t\t\tcontent[ id ] = overrides[ id ];\n\t\t} );\n\n\t\treturn {\n\t\t\t...retainedAttributes,\n\t\t\tcontent,\n\t\t};\n\t},\n};\n\nexport default [ v2, v1 ];\n"],"mappings":"AAAA,MAAMA,QAAQ,GAAKC,GAAG,IACrB,OAAOA,GAAG,KAAK,QAAQ,IAAI,CAAEC,KAAK,CAACC,OAAO,CAAEF,GAAI,CAAC,IAAIA,GAAG,KAAK,IAAI;;AAElE;AACA,MAAMG,EAAE,GAAG;EACVC,UAAU,EAAE;IACXC,GAAG,EAAE;MACJC,IAAI,EAAE;IACP,CAAC;IACDC,OAAO,EAAE;MACRD,IAAI,EAAE;IACP;EACD,CAAC;EACDE,QAAQ,EAAE;IACTC,eAAe,EAAE,KAAK;IACtBC,IAAI,EAAE,KAAK;IACXC,QAAQ,EAAE,KAAK;IACfC,QAAQ,EAAE;EACX,CAAC;EACD;EACA;EACA;EACA;EACA;EACAC,UAAUA,CAAE;IAAEN;EAAQ,CAAC,EAAG;IACzB,OACC,CAAC,CAAEA,OAAO,IACVO,MAAM,CAACC,IAAI,CAAER,OAAQ,CAAC,CAACS,KAAK,CACzBC,UAAU,IACXV,OAAO,CAAEU,UAAU,CAAE,CAACC,MAAM,IAC5BnB,QAAQ,CAAEQ,OAAO,CAAEU,UAAU,CAAE,CAACC,MAAO,CACzC,CAAC;EAEH,CAAC;EACD;AACD;AACA;AACA;AACA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E,EAAE,CAAE;IAChC,CAAE,CAAC;IAEH,OAAO;MACN,GAAGN,kBAAkB;MACrBb;IACD,CAAC;EACF;AACD,CAAC;AAED,eAAe,CAAEJ,EAAE,EAAEoB,EAAE,CAAE"}
|
|
@@ -14,7 +14,7 @@ import { Placeholder, Spinner, ToolbarButton, ToolbarGroup } from '@wordpress/co
|
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
15
|
import { useInnerBlocksProps, RecursionProvider, useHasRecursion, InnerBlocks, useBlockProps, Warning, privateApis as blockEditorPrivateApis, store as blockEditorStore, BlockControls } from '@wordpress/block-editor';
|
|
16
16
|
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
17
|
-
import { parse, cloneBlock } from '@wordpress/blocks';
|
|
17
|
+
import { parse, cloneBlock, store as blocksStore } from '@wordpress/blocks';
|
|
18
18
|
import { RichTextData } from '@wordpress/rich-text';
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -29,6 +29,23 @@ const {
|
|
|
29
29
|
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
30
30
|
} = unlock(patternsPrivateApis);
|
|
31
31
|
const fullAlignments = ['full', 'wide', 'left', 'right'];
|
|
32
|
+
function getLegacyIdMap(blocks, content, nameCount = {}) {
|
|
33
|
+
let idToClientIdMap = {};
|
|
34
|
+
for (const block of blocks) {
|
|
35
|
+
if (block?.innerBlocks?.length) {
|
|
36
|
+
idToClientIdMap = {
|
|
37
|
+
...idToClientIdMap,
|
|
38
|
+
...getLegacyIdMap(block.innerBlocks, content, nameCount)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const id = block.attributes.metadata?.id;
|
|
42
|
+
const clientId = block.clientId;
|
|
43
|
+
if (id && content?.[id]) {
|
|
44
|
+
idToClientIdMap[clientId] = id;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return idToClientIdMap;
|
|
48
|
+
}
|
|
32
49
|
const useInferredLayout = (blocks, parentLayout) => {
|
|
33
50
|
const initialInferredAlignmentRef = useRef();
|
|
34
51
|
return useMemo(() => {
|
|
@@ -65,23 +82,26 @@ function hasOverridableBlocks(blocks) {
|
|
|
65
82
|
function getOverridableAttributes(block) {
|
|
66
83
|
return Object.entries(block.attributes.metadata.bindings).filter(([, binding]) => binding.source === 'core/pattern-overrides').map(([attributeKey]) => attributeKey);
|
|
67
84
|
}
|
|
68
|
-
function applyInitialContentValuesToInnerBlocks(blocks, content = {}, defaultValues) {
|
|
85
|
+
function applyInitialContentValuesToInnerBlocks(blocks, content = {}, defaultValues, legacyIdMap) {
|
|
69
86
|
return blocks.map(block => {
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
var _legacyIdMap$block$cl;
|
|
88
|
+
const innerBlocks = applyInitialContentValuesToInnerBlocks(block.innerBlocks, content, defaultValues, legacyIdMap);
|
|
89
|
+
const metadataName = (_legacyIdMap$block$cl = legacyIdMap?.[block.clientId]) !== null && _legacyIdMap$block$cl !== void 0 ? _legacyIdMap$block$cl : block.attributes.metadata?.name;
|
|
90
|
+
if (!metadataName || !hasOverridableAttributes(block)) {
|
|
91
|
+
return {
|
|
92
|
+
...block,
|
|
93
|
+
innerBlocks
|
|
94
|
+
};
|
|
95
|
+
}
|
|
76
96
|
const attributes = getOverridableAttributes(block);
|
|
77
97
|
const newAttributes = {
|
|
78
98
|
...block.attributes
|
|
79
99
|
};
|
|
80
100
|
for (const attributeKey of attributes) {
|
|
81
|
-
var _defaultValues$
|
|
82
|
-
(_defaultValues$
|
|
83
|
-
defaultValues[
|
|
84
|
-
const contentValues = content[
|
|
101
|
+
var _defaultValues$metada;
|
|
102
|
+
(_defaultValues$metada = defaultValues[metadataName]) !== null && _defaultValues$metada !== void 0 ? _defaultValues$metada : defaultValues[metadataName] = {};
|
|
103
|
+
defaultValues[metadataName][attributeKey] = block.attributes[attributeKey];
|
|
104
|
+
const contentValues = content[metadataName];
|
|
85
105
|
if (contentValues?.[attributeKey] !== undefined) {
|
|
86
106
|
newAttributes[attributeKey] = contentValues[attributeKey];
|
|
87
107
|
}
|
|
@@ -99,25 +119,27 @@ function isAttributeEqual(attribute1, attribute2) {
|
|
|
99
119
|
}
|
|
100
120
|
return attribute1 === attribute2;
|
|
101
121
|
}
|
|
102
|
-
function getContentValuesFromInnerBlocks(blocks, defaultValues) {
|
|
122
|
+
function getContentValuesFromInnerBlocks(blocks, defaultValues, legacyIdMap) {
|
|
103
123
|
/** @type {Record<string, { values: Record<string, unknown>}>} */
|
|
104
124
|
const content = {};
|
|
105
125
|
for (const block of blocks) {
|
|
126
|
+
var _legacyIdMap$block$cl2;
|
|
106
127
|
if (block.name === patternBlockName) continue;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
128
|
+
if (block.innerBlocks.length) {
|
|
129
|
+
Object.assign(content, getContentValuesFromInnerBlocks(block.innerBlocks, defaultValues, legacyIdMap));
|
|
130
|
+
}
|
|
131
|
+
const metadataName = (_legacyIdMap$block$cl2 = legacyIdMap?.[block.clientId]) !== null && _legacyIdMap$block$cl2 !== void 0 ? _legacyIdMap$block$cl2 : block.attributes.metadata?.name;
|
|
132
|
+
if (!metadataName || !hasOverridableAttributes(block)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
110
135
|
const attributes = getOverridableAttributes(block);
|
|
111
136
|
for (const attributeKey of attributes) {
|
|
112
|
-
if (!isAttributeEqual(block.attributes[attributeKey], defaultValues[
|
|
113
|
-
var _content$
|
|
114
|
-
(_content$
|
|
115
|
-
values: {},
|
|
116
|
-
blockName: block.name
|
|
117
|
-
};
|
|
137
|
+
if (!isAttributeEqual(block.attributes[attributeKey], defaultValues?.[metadataName]?.[attributeKey])) {
|
|
138
|
+
var _content$metadataName;
|
|
139
|
+
(_content$metadataName = content[metadataName]) !== null && _content$metadataName !== void 0 ? _content$metadataName : content[metadataName] = {};
|
|
118
140
|
// TODO: We need a way to represent `undefined` in the serialized overrides.
|
|
119
141
|
// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
|
|
120
|
-
content[
|
|
142
|
+
content[metadataName][attributeKey] = block.attributes[attributeKey] === undefined ?
|
|
121
143
|
// TODO: We use an empty string to represent undefined for now until
|
|
122
144
|
// we support a richer format for overrides and the block binding API.
|
|
123
145
|
// Currently only the `linkTarget` attribute of `core/button` is affected.
|
|
@@ -174,7 +196,8 @@ export default function ReusableBlockEdit({
|
|
|
174
196
|
userCanEdit,
|
|
175
197
|
getBlockEditingMode,
|
|
176
198
|
onNavigateToEntityRecord,
|
|
177
|
-
editingMode
|
|
199
|
+
editingMode,
|
|
200
|
+
hasPatternOverridesSource
|
|
178
201
|
} = useSelect(select => {
|
|
179
202
|
const {
|
|
180
203
|
canUser
|
|
@@ -184,6 +207,9 @@ export default function ReusableBlockEdit({
|
|
|
184
207
|
getSettings,
|
|
185
208
|
getBlockEditingMode: _getBlockEditingMode
|
|
186
209
|
} = select(blockEditorStore);
|
|
210
|
+
const {
|
|
211
|
+
getBlockBindingsSource
|
|
212
|
+
} = unlock(select(blocksStore));
|
|
187
213
|
const blocks = getBlocks(patternClientId);
|
|
188
214
|
const canEdit = canUser('update', 'blocks', ref);
|
|
189
215
|
|
|
@@ -193,7 +219,8 @@ export default function ReusableBlockEdit({
|
|
|
193
219
|
userCanEdit: canEdit,
|
|
194
220
|
getBlockEditingMode: _getBlockEditingMode,
|
|
195
221
|
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord,
|
|
196
|
-
editingMode: _getBlockEditingMode(patternClientId)
|
|
222
|
+
editingMode: _getBlockEditingMode(patternClientId),
|
|
223
|
+
hasPatternOverridesSource: !!getBlockBindingsSource('core/pattern-overrides')
|
|
197
224
|
};
|
|
198
225
|
}, [patternClientId, ref]);
|
|
199
226
|
|
|
@@ -201,29 +228,33 @@ export default function ReusableBlockEdit({
|
|
|
201
228
|
useEffect(() => {
|
|
202
229
|
setBlockEditMode(setBlockEditingMode, innerBlocks,
|
|
203
230
|
// Disable editing if the pattern itself is disabled.
|
|
204
|
-
editingMode === 'disabled' ? 'disabled' : undefined);
|
|
205
|
-
}, [editingMode, innerBlocks, setBlockEditingMode]);
|
|
206
|
-
const canOverrideBlocks = useMemo(() => hasOverridableBlocks(innerBlocks), [innerBlocks]);
|
|
231
|
+
editingMode === 'disabled' || !hasPatternOverridesSource ? 'disabled' : undefined);
|
|
232
|
+
}, [editingMode, innerBlocks, setBlockEditingMode, hasPatternOverridesSource]);
|
|
233
|
+
const canOverrideBlocks = useMemo(() => hasPatternOverridesSource && hasOverridableBlocks(innerBlocks), [hasPatternOverridesSource, innerBlocks]);
|
|
207
234
|
const initialBlocks = useMemo(() => {
|
|
208
235
|
var _editedRecord$blocks$;
|
|
209
236
|
return (// Clone the blocks to generate new client IDs.
|
|
210
237
|
(_editedRecord$blocks$ = editedRecord.blocks?.map(block => cloneBlock(block))) !== null && _editedRecord$blocks$ !== void 0 ? _editedRecord$blocks$ : editedRecord.content && typeof editedRecord.content !== 'function' ? parse(editedRecord.content) : []
|
|
211
238
|
);
|
|
212
239
|
}, [editedRecord.blocks, editedRecord.content]);
|
|
240
|
+
const legacyIdMap = useRef({});
|
|
213
241
|
|
|
214
242
|
// Apply the initial overrides from the pattern block to the inner blocks.
|
|
215
243
|
useEffect(() => {
|
|
244
|
+
// Build a map of clientIds to the old nano id system to provide back compat.
|
|
245
|
+
legacyIdMap.current = getLegacyIdMap(initialBlocks, initialContent.current);
|
|
216
246
|
defaultContent.current = {};
|
|
217
247
|
const originalEditingMode = getBlockEditingMode(patternClientId);
|
|
218
248
|
// Replace the contents of the blocks with the overrides.
|
|
219
249
|
registry.batch(() => {
|
|
220
250
|
setBlockEditingMode(patternClientId, 'default');
|
|
221
251
|
syncDerivedUpdates(() => {
|
|
222
|
-
|
|
252
|
+
const blocks = hasPatternOverridesSource ? applyInitialContentValuesToInnerBlocks(initialBlocks, initialContent.current, defaultContent.current, legacyIdMap.current) : initialBlocks;
|
|
253
|
+
replaceInnerBlocks(patternClientId, blocks);
|
|
223
254
|
});
|
|
224
255
|
setBlockEditingMode(patternClientId, originalEditingMode);
|
|
225
256
|
});
|
|
226
|
-
}, [__unstableMarkNextChangeAsNotPersistent, patternClientId, initialBlocks, replaceInnerBlocks, registry, getBlockEditingMode, setBlockEditingMode, syncDerivedUpdates]);
|
|
257
|
+
}, [hasPatternOverridesSource, __unstableMarkNextChangeAsNotPersistent, patternClientId, initialBlocks, replaceInnerBlocks, registry, getBlockEditingMode, setBlockEditingMode, syncDerivedUpdates]);
|
|
227
258
|
const {
|
|
228
259
|
alignment,
|
|
229
260
|
layout
|
|
@@ -245,6 +276,9 @@ export default function ReusableBlockEdit({
|
|
|
245
276
|
// Sync the `content` attribute from the updated blocks to the pattern block.
|
|
246
277
|
// `syncDerivedUpdates` is used here to avoid creating an additional undo level.
|
|
247
278
|
useEffect(() => {
|
|
279
|
+
if (!hasPatternOverridesSource) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
248
282
|
const {
|
|
249
283
|
getBlocks
|
|
250
284
|
} = registry.select(blockEditorStore);
|
|
@@ -255,12 +289,12 @@ export default function ReusableBlockEdit({
|
|
|
255
289
|
prevBlocks = blocks;
|
|
256
290
|
syncDerivedUpdates(() => {
|
|
257
291
|
setAttributes({
|
|
258
|
-
content: getContentValuesFromInnerBlocks(blocks, defaultContent.current)
|
|
292
|
+
content: getContentValuesFromInnerBlocks(blocks, defaultContent.current, legacyIdMap.current)
|
|
259
293
|
});
|
|
260
294
|
});
|
|
261
295
|
}
|
|
262
296
|
}, blockEditorStore);
|
|
263
|
-
}, [syncDerivedUpdates, patternClientId, registry, setAttributes]);
|
|
297
|
+
}, [hasPatternOverridesSource, syncDerivedUpdates, patternClientId, registry, setAttributes]);
|
|
264
298
|
const handleEditOriginal = () => {
|
|
265
299
|
onNavigateToEntityRecord({
|
|
266
300
|
postId: ref,
|