@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.
Files changed (67) hide show
  1. package/build/block/deprecated.js +71 -11
  2. package/build/block/deprecated.js.map +1 -1
  3. package/build/block/edit.js +65 -31
  4. package/build/block/edit.js.map +1 -1
  5. package/build/code/save.js +3 -1
  6. package/build/code/save.js.map +1 -1
  7. package/build/image/edit.js +6 -3
  8. package/build/image/edit.js.map +1 -1
  9. package/build/image/image.js +11 -5
  10. package/build/image/image.js.map +1 -1
  11. package/build/list-item/edit.js +1 -3
  12. package/build/list-item/edit.js.map +1 -1
  13. package/build/list-item/hooks/index.js +0 -7
  14. package/build/list-item/hooks/index.js.map +1 -1
  15. package/build/list-item/index.js +4 -1
  16. package/build/list-item/index.js.map +1 -1
  17. package/build/navigation/edit/index.js +2 -2
  18. package/build/navigation/edit/index.js.map +1 -1
  19. package/build/navigation/edit/navigation-menu-selector.js +20 -19
  20. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  21. package/build/site-logo/edit.js +7 -2
  22. package/build/site-logo/edit.js.map +1 -1
  23. package/build-module/block/deprecated.js +71 -11
  24. package/build-module/block/deprecated.js.map +1 -1
  25. package/build-module/block/edit.js +66 -32
  26. package/build-module/block/edit.js.map +1 -1
  27. package/build-module/code/save.js +3 -1
  28. package/build-module/code/save.js.map +1 -1
  29. package/build-module/image/edit.js +7 -4
  30. package/build-module/image/edit.js.map +1 -1
  31. package/build-module/image/image.js +11 -5
  32. package/build-module/image/image.js.map +1 -1
  33. package/build-module/list-item/edit.js +2 -4
  34. package/build-module/list-item/edit.js.map +1 -1
  35. package/build-module/list-item/hooks/index.js +0 -1
  36. package/build-module/list-item/hooks/index.js.map +1 -1
  37. package/build-module/list-item/index.js +4 -1
  38. package/build-module/list-item/index.js.map +1 -1
  39. package/build-module/navigation/edit/index.js +2 -2
  40. package/build-module/navigation/edit/index.js.map +1 -1
  41. package/build-module/navigation/edit/navigation-menu-selector.js +20 -19
  42. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  43. package/build-module/site-logo/edit.js +7 -2
  44. package/build-module/site-logo/edit.js.map +1 -1
  45. package/build-style/common-rtl.css +1 -0
  46. package/build-style/common.css +1 -0
  47. package/package.json +13 -13
  48. package/src/block/deprecated.js +76 -11
  49. package/src/block/edit.js +100 -32
  50. package/src/block/index.php +21 -12
  51. package/src/code/save.js +7 -1
  52. package/src/image/edit.js +10 -3
  53. package/src/image/image.js +20 -16
  54. package/src/list-item/edit.js +1 -2
  55. package/src/list-item/hooks/index.js +0 -1
  56. package/src/list-item/index.js +3 -0
  57. package/src/navigation/edit/index.js +2 -2
  58. package/src/navigation/edit/navigation-menu-selector.js +34 -16
  59. package/src/navigation/edit/test/navigation-menu-selector.js +61 -39
  60. package/src/navigation/index.php +19 -13
  61. package/src/search/index.php +1 -1
  62. package/src/site-logo/edit.js +10 -5
  63. package/build/list-item/hooks/use-copy.js +0 -39
  64. package/build/list-item/hooks/use-copy.js.map +0 -1
  65. package/build-module/list-item/hooks/use-copy.js +0 -32
  66. package/build-module/list-item/hooks/use-copy.js.map +0 -1
  67. package/src/list-item/hooks/use-copy.js +0 -38
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","isBlobURL","createInterpolateElement","useEffect","useState","useRef","__","isRTL","MenuItem","PanelBody","RangeControl","ResizableBox","Spinner","ToggleControl","ToolbarButton","Placeholder","Button","DropZone","FlexItem","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useViewportMatch","BlockControls","InspectorControls","MediaPlaceholder","MediaUpload","MediaUploadCheck","MediaReplaceFlow","useBlockProps","store","blockEditorStore","__experimentalImageEditor","ImageEditor","useSelect","useDispatch","coreStore","crop","upload","noticesStore","useClientWidth","MIN_SIZE","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","isLargeViewport","isWideAligned","includes","isResizable","naturalWidth","naturalHeight","setNaturalSize","isEditingImage","setIsEditingImage","toggleSelection","classes","imageEditing","maxWidth","title","select","settings","getSettings","siteEntities","getEntityRecord","name","onResizeStart","onResizeStop","img","createElement","className","src","onLoad","event","target","imgWrapper","href","rel","onClick","preventDefault","imageWidthWithinContainer","exceedMaxWidth","style","defaultWidth","currentWidth","ratio","currentHeight","minWidth","Math","ceil","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","canEditImage","imgEdit","id","url","onSaveImage","imageAttributes","onFinishEditing","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","delta","parseInt","syncSiteIconHelpText","a","Fragment","__nextHasNoMarginBottom","__next40pxDefaultSize","label","onChange","newWidth","min","max","initialPosition","value","disabled","checked","undefined","help","group","icon","SiteLogoReplaceFlow","onRemoveLogo","mediaReplaceProps","allowedTypes","accept","InspectorLogoPreview","mediaItemData","itemGroupProps","alt_text","source_url","slug","logoSlug","media_details","logoMediaDetails","logoLabel","sizes","full","file","as","justify","numberOfLines","LogoEdit","ref","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","onUploadError","message","type","onFilesDrop","filesList","mediaUpload","onFileChange","image","onError","mediaReplaceFlowProps","mediaURL","onSelect","controls","logoImage","isLoading","placeholder","content","placeholderClassName","preview","withIllustration","blockProps","mediaInspectorPanel","isBordered","popoverProps","render","open","variant","mediaLibraryButton","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\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AO;QACfyF,WAAW;QACXC,eAAe,EAAC,YAAY;QAC5BnI,OAAO,EAAGA,CAAA,KAAM;UACf+H,IAAI,CAAC,CAAC;QACP;MAAG,CACH,CAAC;IAEJ;EAAG,CACH,CAEE,CAAC;AAER"}
1
+ {"version":3,"names":["classnames","isBlobURL","createInterpolateElement","useEffect","useState","useRef","__","isRTL","MenuItem","PanelBody","RangeControl","ResizableBox","Spinner","ToggleControl","ToolbarButton","Placeholder","Button","DropZone","FlexItem","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useViewportMatch","BlockControls","InspectorControls","MediaPlaceholder","MediaUpload","MediaUploadCheck","MediaReplaceFlow","useBlockProps","store","blockEditorStore","__experimentalImageEditor","ImageEditor","useSelect","useDispatch","coreStore","crop","upload","noticesStore","useClientWidth","MIN_SIZE","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","isLargeViewport","isWideAligned","includes","isResizable","naturalWidth","naturalHeight","setNaturalSize","isEditingImage","setIsEditingImage","toggleSelection","classes","imageEditing","maxWidth","title","select","settings","getSettings","siteEntities","getEntityRecord","name","onResizeStart","onResizeStop","img","createElement","className","src","onLoad","event","target","imgWrapper","href","rel","onClick","preventDefault","imageWidthWithinContainer","exceedMaxWidth","style","defaultWidth","currentWidth","ratio","currentHeight","minWidth","Math","ceil","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","canEditImage","imgEdit","id","url","onSaveImage","imageAttributes","onFinishEditing","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","delta","parseInt","shouldUseNewUrl","window","__experimentalUseCustomizerSiteLogoUrl","siteIconSettingsUrl","syncSiteIconHelpText","a","Fragment","__nextHasNoMarginBottom","__next40pxDefaultSize","label","onChange","newWidth","min","max","initialPosition","value","disabled","checked","undefined","help","group","icon","SiteLogoReplaceFlow","onRemoveLogo","mediaReplaceProps","allowedTypes","accept","InspectorLogoPreview","mediaItemData","itemGroupProps","alt_text","source_url","slug","logoSlug","media_details","logoMediaDetails","logoLabel","sizes","full","file","as","justify","numberOfLines","LogoEdit","ref","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","onUploadError","message","type","onFilesDrop","filesList","mediaUpload","onFileChange","image","onError","mediaReplaceFlowProps","mediaURL","onSelect","controls","logoImage","isLoading","placeholder","content","placeholderClassName","preview","withIllustration","blockProps","mediaInspectorPanel","isBordered","popoverProps","render","open","variant","mediaLibraryButton","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":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,wBAAwB,EACxBC,SAAS,EACTC,QAAQ,EACRC,MAAM,QACA,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,OAAO,EACPC,aAAa,EACbC,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  --wp-block-synced-color--rgb: 122, 0, 223;
99
+ --wp-bound-block-color: #9747ff;
99
100
  }
100
101
  @media (min-resolution: 192dpi) {
101
102
  :root {
@@ -96,6 +96,7 @@
96
96
  --wp-admin-border-width-focus: 2px;
97
97
  --wp-block-synced-color: #7a00df;
98
98
  --wp-block-synced-color--rgb: 122, 0, 223;
99
+ --wp-bound-block-color: #9747ff;
99
100
  }
100
101
  @media (min-resolution: 192dpi) {
101
102
  :root {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.28.4",
3
+ "version": "8.28.6",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,11 +35,11 @@
35
35
  "@wordpress/api-fetch": "^6.48.1",
36
36
  "@wordpress/autop": "^3.51.1",
37
37
  "@wordpress/blob": "^3.51.1",
38
- "@wordpress/block-editor": "^12.19.4",
39
- "@wordpress/blocks": "^12.28.4",
40
- "@wordpress/components": "^26.0.3",
38
+ "@wordpress/block-editor": "^12.19.6",
39
+ "@wordpress/blocks": "^12.28.6",
40
+ "@wordpress/components": "^26.0.5",
41
41
  "@wordpress/compose": "^6.28.1",
42
- "@wordpress/core-data": "^6.28.4",
42
+ "@wordpress/core-data": "^6.28.6",
43
43
  "@wordpress/data": "^9.21.1",
44
44
  "@wordpress/date": "^4.51.1",
45
45
  "@wordpress/deprecated": "^3.51.1",
@@ -49,17 +49,17 @@
49
49
  "@wordpress/hooks": "^3.51.1",
50
50
  "@wordpress/html-entities": "^3.51.1",
51
51
  "@wordpress/i18n": "^4.51.1",
52
- "@wordpress/icons": "^9.42.2",
53
- "@wordpress/interactivity": "^5.0.2",
54
- "@wordpress/interactivity-router": "^1.1.2",
52
+ "@wordpress/icons": "^9.42.4",
53
+ "@wordpress/interactivity": "^5.0.4",
54
+ "@wordpress/interactivity-router": "^1.1.4",
55
55
  "@wordpress/keycodes": "^3.51.1",
56
56
  "@wordpress/notices": "^4.19.1",
57
- "@wordpress/patterns": "^1.12.4",
57
+ "@wordpress/patterns": "^1.12.6",
58
58
  "@wordpress/primitives": "^3.49.1",
59
59
  "@wordpress/private-apis": "^0.33.1",
60
- "@wordpress/reusable-blocks": "^4.28.4",
61
- "@wordpress/rich-text": "^6.28.2",
62
- "@wordpress/server-side-render": "^4.28.4",
60
+ "@wordpress/reusable-blocks": "^4.28.6",
61
+ "@wordpress/rich-text": "^6.28.4",
62
+ "@wordpress/server-side-render": "^4.28.6",
63
63
  "@wordpress/url": "^3.52.1",
64
64
  "@wordpress/viewport": "^5.28.1",
65
65
  "@wordpress/wordcount": "^3.51.1",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "864c1c553cb284def3bd5c907998da45f5c143ea"
83
+ "gitHead": "7d2a00f1998a0a696694802725e523628f994cfc"
84
84
  }
@@ -1,4 +1,75 @@
1
- // v1: Migrate and rename the `overrides` attribute to the `content` attribute.
1
+ const isObject = ( obj ) =>
2
+ typeof obj === 'object' && ! Array.isArray( obj ) && obj !== null;
3
+
4
+ // v2: Migrate to a more condensed version of the 'content' attribute attribute.
5
+ const v2 = {
6
+ attributes: {
7
+ ref: {
8
+ type: 'number',
9
+ },
10
+ content: {
11
+ type: 'object',
12
+ },
13
+ },
14
+ supports: {
15
+ customClassName: false,
16
+ html: false,
17
+ inserter: false,
18
+ renaming: false,
19
+ },
20
+ // Force this deprecation to run whenever there's a values sub-property that's an object.
21
+ //
22
+ // This could fail in the future if a block ever has binding to a `values` attribute.
23
+ // Some extra protection is added to ensure `values` is an object, but this only reduces
24
+ // the likelihood, it doesn't solve it completely.
25
+ isEligible( { content } ) {
26
+ return (
27
+ !! content &&
28
+ Object.keys( content ).every(
29
+ ( contentKey ) =>
30
+ content[ contentKey ].values &&
31
+ isObject( content[ contentKey ].values )
32
+ )
33
+ );
34
+ },
35
+ /*
36
+ * Old attribute format:
37
+ * content: {
38
+ * "V98q_x": {
39
+ * // The attribute values are now stored as a 'values' sub-property.
40
+ * values: { content: 'My content value' },
41
+ * // ... additional metadata, like the block name can be stored here.
42
+ * }
43
+ * }
44
+ *
45
+ * New attribute format:
46
+ * content: {
47
+ * "V98q_x": {
48
+ * content: 'My content value',
49
+ * }
50
+ * }
51
+ */
52
+ migrate( attributes ) {
53
+ const { content, ...retainedAttributes } = attributes;
54
+
55
+ if ( content && Object.keys( content ).length ) {
56
+ const updatedContent = { ...content };
57
+
58
+ for ( const contentKey in content ) {
59
+ updatedContent[ contentKey ] = content[ contentKey ].values;
60
+ }
61
+
62
+ return {
63
+ ...retainedAttributes,
64
+ content: updatedContent,
65
+ };
66
+ }
67
+
68
+ return attributes;
69
+ },
70
+ };
71
+
72
+ // v1: Rename the `overrides` attribute to the `content` attribute.
2
73
  const v1 = {
3
74
  attributes: {
4
75
  ref: {
@@ -23,16 +94,12 @@ const v1 = {
23
94
  * overrides: {
24
95
  * // An key is an id that represents a block.
25
96
  * // The values are the attribute values of the block.
26
- * "V98q_x": { content: 'dwefwefwefwe' }
97
+ * "V98q_x": { content: 'My content value' }
27
98
  * }
28
99
  *
29
100
  * New attribute format:
30
101
  * content: {
31
- * "V98q_x": {
32
- * // The attribute values are now stored as a 'values' sub-property.
33
- * values: { content: 'dwefwefwefwe' },
34
- * // ... additional metadata, like the block name can be stored here.
35
- * }
102
+ * "V98q_x": { content: 'My content value' }
36
103
  * }
37
104
  *
38
105
  */
@@ -42,9 +109,7 @@ const v1 = {
42
109
  const content = {};
43
110
 
44
111
  Object.keys( overrides ).forEach( ( id ) => {
45
- content[ id ] = {
46
- values: overrides[ id ],
47
- };
112
+ content[ id ] = overrides[ id ];
48
113
  } );
49
114
 
50
115
  return {
@@ -54,4 +119,4 @@ const v1 = {
54
119
  },
55
120
  };
56
121
 
57
- export default [ v1 ];
122
+ export default [ v2, v1 ];
package/src/block/edit.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  BlockControls,
29
29
  } from '@wordpress/block-editor';
30
30
  import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
31
- import { parse, cloneBlock } from '@wordpress/blocks';
31
+ import { parse, cloneBlock, store as blocksStore } from '@wordpress/blocks';
32
32
  import { RichTextData } from '@wordpress/rich-text';
33
33
 
34
34
  /**
@@ -42,6 +42,25 @@ const { PARTIAL_SYNCING_SUPPORTED_BLOCKS } = unlock( patternsPrivateApis );
42
42
 
43
43
  const fullAlignments = [ 'full', 'wide', 'left', 'right' ];
44
44
 
45
+ function getLegacyIdMap( blocks, content, nameCount = {} ) {
46
+ let idToClientIdMap = {};
47
+ for ( const block of blocks ) {
48
+ if ( block?.innerBlocks?.length ) {
49
+ idToClientIdMap = {
50
+ ...idToClientIdMap,
51
+ ...getLegacyIdMap( block.innerBlocks, content, nameCount ),
52
+ };
53
+ }
54
+
55
+ const id = block.attributes.metadata?.id;
56
+ const clientId = block.clientId;
57
+ if ( id && content?.[ id ] ) {
58
+ idToClientIdMap[ clientId ] = id;
59
+ }
60
+ }
61
+ return idToClientIdMap;
62
+ }
63
+
45
64
  const useInferredLayout = ( blocks, parentLayout ) => {
46
65
  const initialInferredAlignmentRef = useRef();
47
66
 
@@ -101,25 +120,31 @@ function getOverridableAttributes( block ) {
101
120
  function applyInitialContentValuesToInnerBlocks(
102
121
  blocks,
103
122
  content = {},
104
- defaultValues
123
+ defaultValues,
124
+ legacyIdMap
105
125
  ) {
106
126
  return blocks.map( ( block ) => {
107
127
  const innerBlocks = applyInitialContentValuesToInnerBlocks(
108
128
  block.innerBlocks,
109
129
  content,
110
- defaultValues
130
+ defaultValues,
131
+ legacyIdMap
111
132
  );
112
- const blockId = block.attributes.metadata?.id;
113
- if ( ! hasOverridableAttributes( block ) || ! blockId )
133
+ const metadataName =
134
+ legacyIdMap?.[ block.clientId ] ?? block.attributes.metadata?.name;
135
+
136
+ if ( ! metadataName || ! hasOverridableAttributes( block ) ) {
114
137
  return { ...block, innerBlocks };
138
+ }
139
+
115
140
  const attributes = getOverridableAttributes( block );
116
141
  const newAttributes = { ...block.attributes };
117
142
  for ( const attributeKey of attributes ) {
118
- defaultValues[ blockId ] ??= {};
119
- defaultValues[ blockId ][ attributeKey ] =
143
+ defaultValues[ metadataName ] ??= {};
144
+ defaultValues[ metadataName ][ attributeKey ] =
120
145
  block.attributes[ attributeKey ];
121
146
 
122
- const contentValues = content[ blockId ]?.values;
147
+ const contentValues = content[ metadataName ];
123
148
  if ( contentValues?.[ attributeKey ] !== undefined ) {
124
149
  newAttributes[ attributeKey ] = contentValues[ attributeKey ];
125
150
  }
@@ -142,29 +167,40 @@ function isAttributeEqual( attribute1, attribute2 ) {
142
167
  return attribute1 === attribute2;
143
168
  }
144
169
 
145
- function getContentValuesFromInnerBlocks( blocks, defaultValues ) {
170
+ function getContentValuesFromInnerBlocks( blocks, defaultValues, legacyIdMap ) {
146
171
  /** @type {Record<string, { values: Record<string, unknown>}>} */
147
172
  const content = {};
148
173
  for ( const block of blocks ) {
149
174
  if ( block.name === patternBlockName ) continue;
150
- Object.assign(
151
- content,
152
- getContentValuesFromInnerBlocks( block.innerBlocks, defaultValues )
153
- );
154
- const blockId = block.attributes.metadata?.id;
155
- if ( ! hasOverridableAttributes( block ) || ! blockId ) continue;
175
+ if ( block.innerBlocks.length ) {
176
+ Object.assign(
177
+ content,
178
+ getContentValuesFromInnerBlocks(
179
+ block.innerBlocks,
180
+ defaultValues,
181
+ legacyIdMap
182
+ )
183
+ );
184
+ }
185
+ const metadataName =
186
+ legacyIdMap?.[ block.clientId ] ?? block.attributes.metadata?.name;
187
+ if ( ! metadataName || ! hasOverridableAttributes( block ) ) {
188
+ continue;
189
+ }
190
+
156
191
  const attributes = getOverridableAttributes( block );
192
+
157
193
  for ( const attributeKey of attributes ) {
158
194
  if (
159
195
  ! isAttributeEqual(
160
196
  block.attributes[ attributeKey ],
161
- defaultValues[ blockId ][ attributeKey ]
197
+ defaultValues?.[ metadataName ]?.[ attributeKey ]
162
198
  )
163
199
  ) {
164
- content[ blockId ] ??= { values: {}, blockName: block.name };
200
+ content[ metadataName ] ??= {};
165
201
  // TODO: We need a way to represent `undefined` in the serialized overrides.
166
202
  // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
167
- content[ blockId ].values[ attributeKey ] =
203
+ content[ metadataName ][ attributeKey ] =
168
204
  block.attributes[ attributeKey ] === undefined
169
205
  ? // TODO: We use an empty string to represent undefined for now until
170
206
  // we support a richer format for overrides and the block binding API.
@@ -229,6 +265,7 @@ export default function ReusableBlockEdit( {
229
265
  getBlockEditingMode,
230
266
  onNavigateToEntityRecord,
231
267
  editingMode,
268
+ hasPatternOverridesSource,
232
269
  } = useSelect(
233
270
  ( select ) => {
234
271
  const { canUser } = select( coreStore );
@@ -237,6 +274,7 @@ export default function ReusableBlockEdit( {
237
274
  getSettings,
238
275
  getBlockEditingMode: _getBlockEditingMode,
239
276
  } = select( blockEditorStore );
277
+ const { getBlockBindingsSource } = unlock( select( blocksStore ) );
240
278
  const blocks = getBlocks( patternClientId );
241
279
  const canEdit = canUser( 'update', 'blocks', ref );
242
280
 
@@ -248,6 +286,9 @@ export default function ReusableBlockEdit( {
248
286
  onNavigateToEntityRecord:
249
287
  getSettings().onNavigateToEntityRecord,
250
288
  editingMode: _getBlockEditingMode( patternClientId ),
289
+ hasPatternOverridesSource: !! getBlockBindingsSource(
290
+ 'core/pattern-overrides'
291
+ ),
251
292
  };
252
293
  },
253
294
  [ patternClientId, ref ]
@@ -259,13 +300,20 @@ export default function ReusableBlockEdit( {
259
300
  setBlockEditingMode,
260
301
  innerBlocks,
261
302
  // Disable editing if the pattern itself is disabled.
262
- editingMode === 'disabled' ? 'disabled' : undefined
303
+ editingMode === 'disabled' || ! hasPatternOverridesSource
304
+ ? 'disabled'
305
+ : undefined
263
306
  );
264
- }, [ editingMode, innerBlocks, setBlockEditingMode ] );
307
+ }, [
308
+ editingMode,
309
+ innerBlocks,
310
+ setBlockEditingMode,
311
+ hasPatternOverridesSource,
312
+ ] );
265
313
 
266
314
  const canOverrideBlocks = useMemo(
267
- () => hasOverridableBlocks( innerBlocks ),
268
- [ innerBlocks ]
315
+ () => hasPatternOverridesSource && hasOverridableBlocks( innerBlocks ),
316
+ [ hasPatternOverridesSource, innerBlocks ]
269
317
  );
270
318
 
271
319
  const initialBlocks = useMemo(
@@ -278,26 +326,36 @@ export default function ReusableBlockEdit( {
278
326
  [ editedRecord.blocks, editedRecord.content ]
279
327
  );
280
328
 
329
+ const legacyIdMap = useRef( {} );
330
+
281
331
  // Apply the initial overrides from the pattern block to the inner blocks.
282
332
  useEffect( () => {
333
+ // Build a map of clientIds to the old nano id system to provide back compat.
334
+ legacyIdMap.current = getLegacyIdMap(
335
+ initialBlocks,
336
+ initialContent.current
337
+ );
283
338
  defaultContent.current = {};
284
339
  const originalEditingMode = getBlockEditingMode( patternClientId );
285
340
  // Replace the contents of the blocks with the overrides.
286
341
  registry.batch( () => {
287
342
  setBlockEditingMode( patternClientId, 'default' );
288
343
  syncDerivedUpdates( () => {
289
- replaceInnerBlocks(
290
- patternClientId,
291
- applyInitialContentValuesToInnerBlocks(
292
- initialBlocks,
293
- initialContent.current,
294
- defaultContent.current
295
- )
296
- );
344
+ const blocks = hasPatternOverridesSource
345
+ ? applyInitialContentValuesToInnerBlocks(
346
+ initialBlocks,
347
+ initialContent.current,
348
+ defaultContent.current,
349
+ legacyIdMap.current
350
+ )
351
+ : initialBlocks;
352
+
353
+ replaceInnerBlocks( patternClientId, blocks );
297
354
  } );
298
355
  setBlockEditingMode( patternClientId, originalEditingMode );
299
356
  } );
300
357
  }, [
358
+ hasPatternOverridesSource,
301
359
  __unstableMarkNextChangeAsNotPersistent,
302
360
  patternClientId,
303
361
  initialBlocks,
@@ -333,6 +391,9 @@ export default function ReusableBlockEdit( {
333
391
  // Sync the `content` attribute from the updated blocks to the pattern block.
334
392
  // `syncDerivedUpdates` is used here to avoid creating an additional undo level.
335
393
  useEffect( () => {
394
+ if ( ! hasPatternOverridesSource ) {
395
+ return;
396
+ }
336
397
  const { getBlocks } = registry.select( blockEditorStore );
337
398
  let prevBlocks = getBlocks( patternClientId );
338
399
  return registry.subscribe( () => {
@@ -343,13 +404,20 @@ export default function ReusableBlockEdit( {
343
404
  setAttributes( {
344
405
  content: getContentValuesFromInnerBlocks(
345
406
  blocks,
346
- defaultContent.current
407
+ defaultContent.current,
408
+ legacyIdMap.current
347
409
  ),
348
410
  } );
349
411
  } );
350
412
  }
351
413
  }, blockEditorStore );
352
- }, [ syncDerivedUpdates, patternClientId, registry, setAttributes ] );
414
+ }, [
415
+ hasPatternOverridesSource,
416
+ syncDerivedUpdates,
417
+ patternClientId,
418
+ registry,
419
+ setAttributes,
420
+ ] );
353
421
 
354
422
  const handleEditOriginal = () => {
355
423
  onNavigateToEntityRecord( {