@wordpress/block-library 8.19.3 → 8.19.4

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 (65) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/cover/edit/inspector-controls.js +1 -1
  3. package/build/cover/edit/inspector-controls.js.map +1 -1
  4. package/build/embed/edit.js +17 -0
  5. package/build/embed/edit.js.map +1 -1
  6. package/build/embed/edit.native.js +17 -0
  7. package/build/embed/edit.native.js.map +1 -1
  8. package/build/image/image.js +1 -1
  9. package/build/image/image.js.map +1 -1
  10. package/build/image/view.js +14 -4
  11. package/build/image/view.js.map +1 -1
  12. package/build/latest-posts/edit.js +6 -2
  13. package/build/latest-posts/edit.js.map +1 -1
  14. package/build/media-text/edit.js +1 -1
  15. package/build/media-text/edit.js.map +1 -1
  16. package/build/navigation/edit/deleted-navigation-warning.js +6 -4
  17. package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
  18. package/build/navigation/edit/index.js +3 -2
  19. package/build/navigation/edit/index.js.map +1 -1
  20. package/build/navigation/edit/inner-blocks.js +2 -1
  21. package/build/navigation/edit/inner-blocks.js.map +1 -1
  22. package/build-module/cover/edit/inspector-controls.js +1 -1
  23. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  24. package/build-module/embed/edit.js +17 -0
  25. package/build-module/embed/edit.js.map +1 -1
  26. package/build-module/embed/edit.native.js +17 -0
  27. package/build-module/embed/edit.native.js.map +1 -1
  28. package/build-module/image/image.js +1 -1
  29. package/build-module/image/image.js.map +1 -1
  30. package/build-module/image/view.js +14 -4
  31. package/build-module/image/view.js.map +1 -1
  32. package/build-module/latest-posts/edit.js +6 -2
  33. package/build-module/latest-posts/edit.js.map +1 -1
  34. package/build-module/media-text/edit.js +1 -1
  35. package/build-module/media-text/edit.js.map +1 -1
  36. package/build-module/navigation/edit/deleted-navigation-warning.js +7 -4
  37. package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
  38. package/build-module/navigation/edit/index.js +3 -2
  39. package/build-module/navigation/edit/index.js.map +1 -1
  40. package/build-module/navigation/edit/inner-blocks.js +2 -1
  41. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  42. package/build-style/image/style-rtl.css +17 -2
  43. package/build-style/image/style.css +17 -2
  44. package/build-style/post-featured-image/style-rtl.css +3 -0
  45. package/build-style/post-featured-image/style.css +3 -0
  46. package/build-style/post-template/style-rtl.css +25 -0
  47. package/build-style/post-template/style.css +25 -0
  48. package/build-style/style-rtl.css +46 -2
  49. package/build-style/style.css +46 -2
  50. package/package.json +32 -32
  51. package/src/cover/edit/inspector-controls.js +1 -1
  52. package/src/embed/edit.js +15 -0
  53. package/src/embed/edit.native.js +15 -0
  54. package/src/image/image.js +1 -1
  55. package/src/image/index.php +64 -46
  56. package/src/image/style.scss +23 -2
  57. package/src/image/view.js +14 -4
  58. package/src/latest-posts/edit.js +10 -2
  59. package/src/latest-posts/index.php +18 -8
  60. package/src/media-text/edit.js +1 -1
  61. package/src/navigation/edit/deleted-navigation-warning.js +9 -4
  62. package/src/navigation/edit/index.js +26 -17
  63. package/src/navigation/edit/inner-blocks.js +1 -0
  64. package/src/post-featured-image/style.scss +4 -0
  65. package/src/post-template/style.scss +20 -0
@@ -1 +1 @@
1
- {"version":3,"names":["createUpgradedEmbedBlock","getClassNames","removeAspectRatioClasses","fallback","getEmbedInfoByProvider","getMergedAttributesWithPreview","EmbedControls","embedContentIcon","EmbedLoading","EmbedPlaceholder","EmbedPreview","EmbedLinkSettings","classnames","_x","useCallback","useState","useEffect","useDispatch","useSelect","useBlockProps","store","blockEditorStore","coreStore","View","PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedInfoByProvider","wasBlockJustInserted","select","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","mergedAttributes","upgradedBlock","onEditURL","value","blockClass","blockProps","createElement","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","Fragment","label","onPress","event","tryAgain","openEmbedLinkSettings","blockSupportsResponsive","isDefaultEmbedInfo","autoFocus","isVisible","onClose","onSubmit","withBottomSheet"],"sources":["@wordpress/block-library/src/embed/edit.native.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] =\n\t\tuseState( isEditingURL );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\thasFinishedResolution,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! url ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t\t'getEmbedPreview',\n\t\t\t\t\t[ url ]\n\t\t\t\t);\n\t\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ url ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url, cannotEmbed, fetching ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tsetAttributes( mergedAttributes );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect(\n\t\t() => setShowEmbedBottomSheet( isEditingURL ),\n\t\t[ isEditingURL ]\n\t);\n\n\tconst onEditURL = useCallback(\n\t\t( value ) => {\n\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\tif ( attributes.url !== value ) {\n\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\tattributes.className\n\t\t\t\t);\n\t\t\t\tsetAttributes( { className: blockClass } );\n\t\t\t}\n\n\t\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t\t// for creating the new block.\n\t\t\tsetAttributes( { url: value } );\n\t\t\tsetIsEditingURL( false );\n\t\t},\n\t\t[ attributes, setAttributes ]\n\t);\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\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AyB;IACnDyC,uBAAuB,EAAG9D,UAAY;IACtCuC,eAAe,EAAGA,eAAiB;IACnCD,gBAAgB,EAAGA,gBAAkB;IACrCrC,GAAG,EAAGA,GAAK;IACXsD,SAAS,EAAGA,SAAW;IACvBT,SAAS,EAAGA;EAAW,CACvB,CAAC,EACFI,aAAA,CAAC5D,IAAI;IAAA,GAAM2D;EAAU,GACpBC,aAAA,CAACzE,YAAY;IACZoB,KAAK,EAAGA,KAAO;IACf2C,SAAS,EAAGA,SAAW;IACvBjC,QAAQ,EAAGA,QAAU;IACrBG,IAAI,EAAGA,IAAM;IACbL,iBAAiB,EAAGA,iBAAmB;IACvCH,UAAU,EAAGA,UAAY;IACzBuD,KAAK,EAAGhD,KAAO;IACfH,OAAO,EAAGA,OAAS;IACnBa,OAAO,EAAGA,OAAS;IACnBkC,qBAAqB,EAAGA,qBAAuB;IAC/CtD,WAAW,EAAGA,WAAa;IAC3BiC,IAAI,EAAGA,IAAM;IACb/B,GAAG,EAAGA,GAAK;IACX8D,kBAAkB,EAAG,CAAEpD;EAAqB,CAC5C,CACI,CACL,CACF,EACDuC,aAAA,CAACxE;EACA;EAAA;IACAsF,SAAS;IACTjB,KAAK,EAAG9C,GAAK;IACbwD,KAAK,EAAGF,SAAW;IACnBU,SAAS,EAAGjD,oBAAsB;IAClCkD,OAAO,EAAGA,CAAA,KAAMjD,uBAAuB,CAAE,KAAM,CAAG;IAClDkD,QAAQ,EAAGrB,SAAW;IACtBsB,eAAe;EAAA,CACf,CACA,CAAC;AAEL,CAAC;AAED,eAAe1E,SAAS"}
1
+ {"version":3,"names":["createUpgradedEmbedBlock","getClassNames","removeAspectRatioClasses","fallback","getEmbedInfoByProvider","getMergedAttributesWithPreview","EmbedControls","embedContentIcon","EmbedLoading","EmbedPlaceholder","EmbedPreview","EmbedLinkSettings","classnames","_x","useCallback","useState","useEffect","useDispatch","useSelect","useBlockProps","store","blockEditorStore","coreStore","View","getAuthority","PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedInfoByProvider","wasBlockJustInserted","select","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","URL","host","toString","mergedAttributes","upgradedBlock","onEditURL","value","blockClass","blockProps","createElement","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","Fragment","label","onPress","event","tryAgain","openEmbedLinkSettings","blockSupportsResponsive","isDefaultEmbedInfo","autoFocus","isVisible","onClose","onSubmit","withBottomSheet"],"sources":["@wordpress/block-library/src/embed/edit.native.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\nimport { getAuthority } from '@wordpress/url';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] =\n\t\tuseState( isEditingURL );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\thasFinishedResolution,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! url ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t\t'getEmbedPreview',\n\t\t\t\t\t[ url ]\n\t\t\t\t);\n\t\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ url ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url, cannotEmbed, fetching ] );\n\n\t// Try a different provider in case the embed url is not supported.\n\tuseEffect( () => {\n\t\tif ( ! cannotEmbed || fetching || ! url ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Until X provider is supported in WordPress, as a workaround we use Twitter provider.\n\t\tif ( getAuthority( url ) === 'x.com' ) {\n\t\t\tconst newURL = new URL( url );\n\t\t\tnewURL.host = 'twitter.com';\n\t\t\tsetAttributes( { url: newURL.toString() } );\n\t\t}\n\t}, [ url, cannotEmbed, fetching, setAttributes ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tsetAttributes( mergedAttributes );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect(\n\t\t() => setShowEmbedBottomSheet( isEditingURL ),\n\t\t[ isEditingURL ]\n\t);\n\n\tconst onEditURL = useCallback(\n\t\t( value ) => {\n\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\tif ( attributes.url !== value ) {\n\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\tattributes.className\n\t\t\t\t);\n\t\t\t\tsetAttributes( { className: blockClass } );\n\t\t\t}\n\n\t\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t\t// for creating the new block.\n\t\t\tsetAttributes( { url: value } );\n\t\t\tsetIsEditingURL( false );\n\t\t},\n\t\t[ attributes, setAttributes ]\n\t);\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,wBAAwB,EACxBC,aAAa,EACbC,wBAAwB,EACxBC,QAAQ,EACRC,sBAAsB,EACtBC,8BAA8B,QACxB,QAAQ;AACf,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,iBAAiB,MAAM,uBAAuB;;AAErD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACrE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,IAAI,QAAQ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E,IAAI;IAAA,GAAM+D;EAAU,GACpBC,aAAA,CAAC7E,YAAY;IACZqB,KAAK,EAAGA,KAAO;IACf2C,SAAS,EAAGA,SAAW;IACvBjC,QAAQ,EAAGA,QAAU;IACrBG,IAAI,EAAGA,IAAM;IACbL,iBAAiB,EAAGA,iBAAmB;IACvCH,UAAU,EAAGA,UAAY;IACzB0D,KAAK,EAAGnD,KAAO;IACfH,OAAO,EAAGA,OAAS;IACnBa,OAAO,EAAGA,OAAS;IACnBqC,qBAAqB,EAAGA,qBAAuB;IAC/CzD,WAAW,EAAGA,WAAa;IAC3BiC,IAAI,EAAGA,IAAM;IACb/B,GAAG,EAAGA,GAAK;IACXiE,kBAAkB,EAAG,CAAEvD;EAAqB,CAC5C,CACI,CACL,CACF,EACD0C,aAAA,CAAC5E;EACA;EAAA;IACA0F,SAAS;IACTjB,KAAK,EAAGjD,GAAK;IACb2D,KAAK,EAAGF,SAAW;IACnBU,SAAS,EAAGpD,oBAAsB;IAClCqD,OAAO,EAAGA,CAAA,KAAMpD,uBAAuB,CAAE,KAAM,CAAG;IAClDqD,QAAQ,EAAGrB,SAAW;IACtBsB,eAAe;EAAA,CACf,CACA,CAAC;AAEL,CAAC;AAED,eAAe7E,SAAS"}
@@ -301,7 +301,7 @@ export default function Image({
301
301
  });
302
302
  const lightboxSetting = useSetting('lightbox');
303
303
  const showLightboxToggle = !!lightbox || lightboxSetting?.allowEditing === true;
304
- const lightboxChecked = lightbox?.enabled || !lightbox && lightboxSetting?.enabled;
304
+ const lightboxChecked = !!lightbox?.enabled || !lightbox && !!lightboxSetting?.enabled;
305
305
  const dimensionsControl = createElement(DimensionsTool, {
306
306
  value: {
307
307
  width,
@@ -1 +1 @@
1
- {"version":3,"names":["isBlobURL","ExternalLink","ResizableBox","Spinner","TextareaControl","ToggleControl","TextControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUseCustomUnits","useCustomUnits","useViewportMatch","usePrevious","useSelect","useDispatch","BlockControls","InspectorControls","RichText","__experimentalImageURLInputUI","ImageURLInputUI","MediaReplaceFlow","store","blockEditorStore","useSetting","BlockAlignmentControl","__experimentalImageEditor","ImageEditor","__experimentalGetElementClassName","__experimentalUseBorderProps","useBorderProps","privateApis","blockEditorPrivateApis","useEffect","useMemo","useState","useRef","useCallback","__","_x","sprintf","isRTL","getFilename","createBlock","getDefaultBlockName","switchToBlockType","crop","overlayText","upload","caption","captionIcon","noticesStore","coreStore","unlock","createUpgradedEmbedBlock","useClientWidth","isExternalImage","MIN_SIZE","ALLOWED_MEDIA_TYPES","evalAspectRatio","DimensionsTool","ResolutionTool","scaleOptions","value","label","help","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","lightbox","numericWidth","parseInt","undefined","numericHeight","imageRef","prevCaption","showCaption","setShowCaption","allowResize","getBlock","image","multiImageSelection","select","getMedia","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","createErrorNotice","createSuccessNotice","isLargeViewport","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","window","fetch","then","response","blob","catch","captionRef","node","focus","naturalWidth","naturalHeight","current","complete","onResizeStart","onResizeStop","onImageError","embedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","type","allowedTypes","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","dimensionsUnitsOptions","availableUnits","lightboxSetting","showLightboxToggle","allowEditing","lightboxChecked","enabled","dimensionsControl","createElement","onChange","newWidth","newHeight","newScale","newAspectRatio","defaultScale","defaultAspectRatio","unitsOptions","resetAll","sizeControls","controls","Fragment","group","onClick","icon","isPressed","onChangeUrl","mediaUrl","mediaLink","link","mediaId","mediaURL","accept","onSelect","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","options","checked","newValue","filename","defaultedAlt","borderProps","isRounded","className","src","onLoad","event","target","ref","style","objectFit","fallbackClientWidth","onSaveImage","imageAttributes","onFinishEditing","numericRatio","customRatio","naturalRatio","ratio","currentWidth","currentHeight","minWidth","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","offsetWidth","String","resizeRatio","isEmpty","identifier","tagName","placeholder","inlineToolbar","__unstableOnSplitAtEnd"],"sources":["@wordpress/block-library/src/image/image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tToggleControl,\n\tTextControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tuseSetting,\n\tBlockAlignmentControl,\n\t__experimentalImageEditor as ImageEditor,\n\t__experimentalGetElementClassName,\n\t__experimentalUseBorderProps as useBorderProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tcrop,\n\toverlayText,\n\tupload,\n\tcaption as captionIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport useClientWidth from './use-client-width';\nimport { isExternalImage } from './edit';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';\nimport { evalAspectRatio } from './utils';\n\nconst { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nexport default function Image( {\n\ttemporaryURL,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontainerRef,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t\tlightbox,\n\t} = attributes;\n\n\t// The only supported unit is px, so we can parseInt to strip the px here.\n\tconst numericWidth = width ? parseInt( width, 10 ) : undefined;\n\tconst numericHeight = height ? parseInt( height, 10 ) : undefined;\n\n\tconst imageRef = useRef();\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst { allowResize = true } = context;\n\tconst { getBlock } = useSelect( blockEditorStore );\n\n\tconst { image, multiImageSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia } = select( coreStore );\n\t\t\tconst { getMultiSelectedBlockClientIds, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst multiSelectedClientIds = getMultiSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tid && isSelected\n\t\t\t\t\t\t? getMedia( id, { context: 'view' } )\n\t\t\t\t\t\t: null,\n\t\t\t\tmultiImageSelection:\n\t\t\t\t\tmultiSelectedClientIds.length &&\n\t\t\t\t\tmultiSelectedClientIds.every(\n\t\t\t\t\t\t( _clientId ) =>\n\t\t\t\t\t\t\tgetBlockName( _clientId ) === 'core/image'\n\t\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id, isSelected ]\n\t);\n\tconst { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetSettings,\n\t\t\t\t\tcanInsertBlockType,\n\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst settings = getSettings();\n\n\t\t\t\treturn {\n\t\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t\t'core/cover',\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\tconst { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst [ externalBlob, setExternalBlob ] = useState();\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! ( isWideAligned && isLargeViewport );\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\tconst canUploadMedia = !! mediaUpload;\n\n\t// If an image is externally hosted, try to fetch the image data. This may\n\t// fail if the image host doesn't allow CORS with the domain. If it works,\n\t// we can enable a button in the toolbar to upload the image.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isExternalImage( id, url ) ||\n\t\t\t! isSelected ||\n\t\t\t! canUploadMedia\n\t\t) {\n\t\t\tsetExternalBlob();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( externalBlob ) return;\n\n\t\twindow\n\t\t\t// Avoid cache, which seems to help avoid CORS problems.\n\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t.then( ( response ) => response.blob() )\n\t\t\t.then( ( blob ) => setExternalBlob( blob ) )\n\t\t\t// Do nothing, cannot upload.\n\t\t\t.catch( () => {} );\n\t}, [ id, url, isSelected, externalBlob, canUploadMedia ] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\t// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageRef.current?.naturalWidth ||\n\t\t\t\tloadedNaturalWidth ||\n\t\t\t\tundefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageRef.current?.naturalHeight ||\n\t\t\t\tloadedNaturalHeight ||\n\t\t\t\tundefined,\n\t\t};\n\t}, [\n\t\tloadedNaturalWidth,\n\t\tloadedNaturalHeight,\n\t\timageRef.current?.complete,\n\t] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tfunction onImageError() {\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\n\t\tif ( undefined !== embedBlock ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tmediaUpload( {\n\t\t\tfilesList: [ externalBlob ],\n\t\t\tonFileChange( [ img ] ) {\n\t\t\t\tonSelectImage( img );\n\n\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetExternalBlob();\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\tscale: undefined,\n\t\t\t }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t\tif ( ! caption ) {\n\t\t\t\tsetShowCaption( false );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tconst canEditImage = id && naturalWidth && naturalHeight && imageEditing;\n\tconst allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox and ImageEditor components. Calculations later on\n\t// for those components are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst lightboxSetting = useSetting( 'lightbox' );\n\n\tconst showLightboxToggle =\n\t\t!! lightbox || lightboxSetting?.allowEditing === true;\n\n\tconst lightboxChecked =\n\t\tlightbox?.enabled || ( ! lightbox && lightboxSetting?.enabled );\n\n\tconst dimensionsControl = (\n\t\t<DimensionsTool\n\t\t\tvalue={ { width, height, scale, aspectRatio } }\n\t\t\tonChange={ ( {\n\t\t\t\twidth: newWidth,\n\t\t\t\theight: newHeight,\n\t\t\t\tscale: newScale,\n\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t} ) => {\n\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\tsetAttributes( {\n\t\t\t\t\t// CSS includes `height: auto`, but we need\n\t\t\t\t\t// `width: auto` to fix the aspect ratio when\n\t\t\t\t\t// only height is set due to the width and\n\t\t\t\t\t// height attributes set via the server.\n\t\t\t\t\twidth: ! newWidth && newHeight ? 'auto' : newWidth,\n\t\t\t\t\theight: newHeight,\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdefaultScale=\"cover\"\n\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\tscaleOptions={ scaleOptions }\n\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t/>\n\t);\n\n\tconst resetAll = () => {\n\t\tsetAttributes( {\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\tscale: undefined,\n\t\t\taspectRatio: undefined,\n\t\t\tlightbox: undefined,\n\t\t} );\n\t};\n\n\tconst sizeControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>\n\t\t\t\t{ isResizable && dimensionsControl }\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowCrop && (\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\t{ ! multiImageSelection && canInsertCover && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ ! multiImageSelection && externalBlob && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload external image' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>\n\t\t\t\t\t{ ! multiImageSelection && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t\thasValue={ () => alt !== '' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tvalue={ alt }\n\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/WAI/tutorials/images/decision-tree\">\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'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\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\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isResizable && dimensionsControl }\n\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showLightboxToggle && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! lightbox }\n\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { lightbox: undefined } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\t\tchecked={ lightboxChecked }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlightbox: { enabled: newValue },\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/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\thelp={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Describe the role of this image on the page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'(Note: many devices and browsers do not display this text.)'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst isRounded = attributes.className?.includes( 'is-style-rounded' );\n\n\tlet img = (\n\t\t// Disable reason: Image itself is not meant to be interactive, but\n\t\t// should direct focus to block.\n\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\talt={ defaultedAlt }\n\t\t\t\tonError={ () => onImageError() }\n\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\tsetLoadedNaturalSize( {\n\t\t\t\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\t\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tref={ imageRef }\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\theight:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ temporaryURL && <Spinner /> }\n\t\t</>\n\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t);\n\n\t// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0\n\t// So we try using the imageRef width first and fallback to clientWidth.\n\tconst fallbackClientWidth = imageRef.current?.width || clientWidth;\n\n\tif ( canEditImage && isEditingImage ) {\n\t\timg = (\n\t\t\t<ImageEditor\n\t\t\t\tid={ id }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ numericWidth }\n\t\t\t\theight={ numericHeight }\n\t\t\t\tclientWidth={ fallbackClientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) =>\n\t\t\t\t\tsetAttributes( imageAttributes )\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\tborderProps={ isRounded ? undefined : borderProps }\n\t\t\t/>\n\t\t);\n\t} else if ( ! isResizable ) {\n\t\timg = <div style={ { width, height, aspectRatio } }>{ img }</div>;\n\t} else {\n\t\tconst numericRatio = aspectRatio && evalAspectRatio( aspectRatio );\n\t\tconst customRatio = numericWidth / numericHeight;\n\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\tconst ratio = numericRatio || customRatio || naturalRatio || 1;\n\t\tconst currentWidth =\n\t\t\t! numericWidth && numericHeight\n\t\t\t\t? numericHeight * ratio\n\t\t\t\t: numericWidth;\n\t\tconst currentHeight =\n\t\t\t! numericHeight && numericWidth\n\t\t\t\t? numericWidth / ratio\n\t\t\t\t: numericHeight;\n\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\n\t\timg = (\n\t\t\t<ResizableBox\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! width && ! height && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} }\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth ?? 'auto',\n\t\t\t\t\theight: currentHeight ?? 'auto',\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={ ratio }\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 ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\t// Since the aspect ratio is locked when resizing, we can\n\t\t\t\t\t// use the width of the resized element to calculate the\n\t\t\t\t\t// height in CSS to prevent stretching when the max-width\n\t\t\t\t\t// is reached.\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: `${ elt.offsetWidth }px`,\n\t\t\t\t\t\theight: 'auto',\n\t\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t\tratio === naturalRatio\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: String( ratio ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</ResizableBox>\n\t\t);\n\t}\n\n\tif ( ! url && ! temporaryURL ) {\n\t\treturn sizeControls;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Hide controls during upload to avoid component remount,\n\t\t\t\twhich causes duplicated image upload. */ }\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ img }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Image caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,YAAY,EACZC,YAAY,EACZC,OAAO,EACPC,eAAe,EACfC,aAAa,EACbC,WAAW,EACXC,aA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,CAAEhO,OAAQ,CAAC,IAAIqB,UAAU,CAAE,IAC9CiI,aAAA,CAACrL,QAAQ;IACRgQ,UAAU,EAAC,SAAS;IACpBvC,SAAS,EAAG/M,iCAAiC,CAC5C,SACD,CAAG;IACHoN,GAAG,EAAGlF,UAAY;IAClBqH,OAAO,EAAC,YAAY;IACpB,cAAa7O,EAAE,CAAE,oBAAqB,CAAG;IACzC8O,WAAW,EAAG9O,EAAE,CAAE,aAAc,CAAG;IACnCyB,KAAK,EAAGd,OAAS;IACjBuJ,QAAQ,EAAKzI,KAAK,IACjBM,aAAa,CAAE;MAAEpB,OAAO,EAAEc;IAAM,CAAE,CAClC;IACDsN,aAAa;IACbC,sBAAsB,EAAGA,CAAA,KACxB/M,iBAAiB,CAChB5B,WAAW,CAAEC,mBAAmB,CAAC,CAAE,CACpC;EACA,CACD,CAEF,CAAC;AAEL"}
1
+ {"version":3,"names":["isBlobURL","ExternalLink","ResizableBox","Spinner","TextareaControl","ToggleControl","TextControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUseCustomUnits","useCustomUnits","useViewportMatch","usePrevious","useSelect","useDispatch","BlockControls","InspectorControls","RichText","__experimentalImageURLInputUI","ImageURLInputUI","MediaReplaceFlow","store","blockEditorStore","useSetting","BlockAlignmentControl","__experimentalImageEditor","ImageEditor","__experimentalGetElementClassName","__experimentalUseBorderProps","useBorderProps","privateApis","blockEditorPrivateApis","useEffect","useMemo","useState","useRef","useCallback","__","_x","sprintf","isRTL","getFilename","createBlock","getDefaultBlockName","switchToBlockType","crop","overlayText","upload","caption","captionIcon","noticesStore","coreStore","unlock","createUpgradedEmbedBlock","useClientWidth","isExternalImage","MIN_SIZE","ALLOWED_MEDIA_TYPES","evalAspectRatio","DimensionsTool","ResolutionTool","scaleOptions","value","label","help","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","lightbox","numericWidth","parseInt","undefined","numericHeight","imageRef","prevCaption","showCaption","setShowCaption","allowResize","getBlock","image","multiImageSelection","select","getMedia","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","createErrorNotice","createSuccessNotice","isLargeViewport","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","window","fetch","then","response","blob","catch","captionRef","node","focus","naturalWidth","naturalHeight","current","complete","onResizeStart","onResizeStop","onImageError","embedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","type","allowedTypes","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","dimensionsUnitsOptions","availableUnits","lightboxSetting","showLightboxToggle","allowEditing","lightboxChecked","enabled","dimensionsControl","createElement","onChange","newWidth","newHeight","newScale","newAspectRatio","defaultScale","defaultAspectRatio","unitsOptions","resetAll","sizeControls","controls","Fragment","group","onClick","icon","isPressed","onChangeUrl","mediaUrl","mediaLink","link","mediaId","mediaURL","accept","onSelect","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","options","checked","newValue","filename","defaultedAlt","borderProps","isRounded","className","src","onLoad","event","target","ref","style","objectFit","fallbackClientWidth","onSaveImage","imageAttributes","onFinishEditing","numericRatio","customRatio","naturalRatio","ratio","currentWidth","currentHeight","minWidth","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","display","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","offsetWidth","String","resizeRatio","isEmpty","identifier","tagName","placeholder","inlineToolbar","__unstableOnSplitAtEnd"],"sources":["@wordpress/block-library/src/image/image.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tExternalLink,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl,\n\tToggleControl,\n\tTextControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useViewportMatch, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tuseSetting,\n\tBlockAlignmentControl,\n\t__experimentalImageEditor as ImageEditor,\n\t__experimentalGetElementClassName,\n\t__experimentalUseBorderProps as useBorderProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tcrop,\n\toverlayText,\n\tupload,\n\tcaption as captionIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport useClientWidth from './use-client-width';\nimport { isExternalImage } from './edit';\n\n/**\n * Module constants\n */\nimport { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';\nimport { evalAspectRatio } from './utils';\n\nconst { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nexport default function Image( {\n\ttemporaryURL,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontainerRef,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t\tlightbox,\n\t} = attributes;\n\n\t// The only supported unit is px, so we can parseInt to strip the px here.\n\tconst numericWidth = width ? parseInt( width, 10 ) : undefined;\n\tconst numericHeight = height ? parseInt( height, 10 ) : undefined;\n\n\tconst imageRef = useRef();\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst { allowResize = true } = context;\n\tconst { getBlock } = useSelect( blockEditorStore );\n\n\tconst { image, multiImageSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia } = select( coreStore );\n\t\t\tconst { getMultiSelectedBlockClientIds, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst multiSelectedClientIds = getMultiSelectedBlockClientIds();\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tid && isSelected\n\t\t\t\t\t\t? getMedia( id, { context: 'view' } )\n\t\t\t\t\t\t: null,\n\t\t\t\tmultiImageSelection:\n\t\t\t\t\tmultiSelectedClientIds.length &&\n\t\t\t\t\tmultiSelectedClientIds.every(\n\t\t\t\t\t\t( _clientId ) =>\n\t\t\t\t\t\t\tgetBlockName( _clientId ) === 'core/image'\n\t\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id, isSelected ]\n\t);\n\tconst { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\tgetSettings,\n\t\t\t\t\tcanInsertBlockType,\n\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst settings = getSettings();\n\n\t\t\t\treturn {\n\t\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t\t'core/cover',\n\t\t\t\t\t\trootClientId\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\tconst { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ isEditingImage, setIsEditingImage ] = useState( false );\n\tconst [ externalBlob, setExternalBlob ] = useState();\n\tconst clientWidth = useClientWidth( containerRef, [ align ] );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! ( isWideAligned && isLargeViewport );\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\tconst canUploadMedia = !! mediaUpload;\n\n\t// If an image is externally hosted, try to fetch the image data. This may\n\t// fail if the image host doesn't allow CORS with the domain. If it works,\n\t// we can enable a button in the toolbar to upload the image.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isExternalImage( id, url ) ||\n\t\t\t! isSelected ||\n\t\t\t! canUploadMedia\n\t\t) {\n\t\t\tsetExternalBlob();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( externalBlob ) return;\n\n\t\twindow\n\t\t\t// Avoid cache, which seems to help avoid CORS problems.\n\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t.then( ( response ) => response.blob() )\n\t\t\t.then( ( blob ) => setExternalBlob( blob ) )\n\t\t\t// Do nothing, cannot upload.\n\t\t\t.catch( () => {} );\n\t}, [ id, url, isSelected, externalBlob, canUploadMedia ] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\t// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageRef.current?.naturalWidth ||\n\t\t\t\tloadedNaturalWidth ||\n\t\t\t\tundefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageRef.current?.naturalHeight ||\n\t\t\t\tloadedNaturalHeight ||\n\t\t\t\tundefined,\n\t\t};\n\t}, [\n\t\tloadedNaturalWidth,\n\t\tloadedNaturalHeight,\n\t\timageRef.current?.complete,\n\t] );\n\n\tfunction onResizeStart() {\n\t\ttoggleSelection( false );\n\t}\n\n\tfunction onResizeStop() {\n\t\ttoggleSelection( true );\n\t}\n\n\tfunction onImageError() {\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\n\t\tif ( undefined !== embedBlock ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tmediaUpload( {\n\t\t\tfilesList: [ externalBlob ],\n\t\t\tonFileChange( [ img ] ) {\n\t\t\t\tonSelectImage( img );\n\n\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetExternalBlob();\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tfunction updateAlignment( nextAlign ) {\n\t\tconst extraUpdatedAttributes = [ 'wide', 'full' ].includes( nextAlign )\n\t\t\t? {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\tscale: undefined,\n\t\t\t }\n\t\t\t: {};\n\t\tsetAttributes( {\n\t\t\t...extraUpdatedAttributes,\n\t\t\talign: nextAlign,\n\t\t} );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingImage( false );\n\t\t\tif ( ! caption ) {\n\t\t\t\tsetShowCaption( false );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tconst canEditImage = id && naturalWidth && naturalHeight && imageEditing;\n\tconst allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox and ImageEditor components. Calculations later on\n\t// for those components are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst lightboxSetting = useSetting( 'lightbox' );\n\n\tconst showLightboxToggle =\n\t\t!! lightbox || lightboxSetting?.allowEditing === true;\n\n\tconst lightboxChecked =\n\t\t!! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );\n\n\tconst dimensionsControl = (\n\t\t<DimensionsTool\n\t\t\tvalue={ { width, height, scale, aspectRatio } }\n\t\t\tonChange={ ( {\n\t\t\t\twidth: newWidth,\n\t\t\t\theight: newHeight,\n\t\t\t\tscale: newScale,\n\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t} ) => {\n\t\t\t\t// Rebuilding the object forces setting `undefined`\n\t\t\t\t// for values that are removed since setAttributes\n\t\t\t\t// doesn't do anything with keys that aren't set.\n\t\t\t\tsetAttributes( {\n\t\t\t\t\t// CSS includes `height: auto`, but we need\n\t\t\t\t\t// `width: auto` to fix the aspect ratio when\n\t\t\t\t\t// only height is set due to the width and\n\t\t\t\t\t// height attributes set via the server.\n\t\t\t\t\twidth: ! newWidth && newHeight ? 'auto' : newWidth,\n\t\t\t\t\theight: newHeight,\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdefaultScale=\"cover\"\n\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\tscaleOptions={ scaleOptions }\n\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t/>\n\t);\n\n\tconst resetAll = () => {\n\t\tsetAttributes( {\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\tscale: undefined,\n\t\t\taspectRatio: undefined,\n\t\t\tlightbox: undefined,\n\t\t} );\n\t};\n\n\tconst sizeControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>\n\t\t\t\t{ isResizable && dimensionsControl }\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\tvalue={ align }\n\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ hasNonContentControls && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowCrop && (\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\t{ ! multiImageSelection && canInsertCover && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ ! multiImageSelection && ! isEditingImage && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ ! multiImageSelection && externalBlob && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload external image' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>\n\t\t\t\t\t{ ! multiImageSelection && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t\thasValue={ () => alt !== '' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tvalue={ alt }\n\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/WAI/tutorials/images/decision-tree\">\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'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\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\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isResizable && dimensionsControl }\n\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showLightboxToggle && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! lightbox }\n\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { lightbox: undefined } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Expand on Click' ) }\n\t\t\t\t\t\t\t\tchecked={ lightboxChecked }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlightbox: { enabled: newValue },\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/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\thelp={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Describe the role of this image on the page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'(Note: many devices and browsers do not display this text.)'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t</>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst isRounded = attributes.className?.includes( 'is-style-rounded' );\n\n\tlet img = (\n\t\t// Disable reason: Image itself is not meant to be interactive, but\n\t\t// should direct focus to block.\n\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\talt={ defaultedAlt }\n\t\t\t\tonError={ () => onImageError() }\n\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\tsetLoadedNaturalSize( {\n\t\t\t\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\t\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tref={ imageRef }\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\theight:\n\t\t\t\t\t\t( width && height ) || aspectRatio ? '100%' : undefined,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ temporaryURL && <Spinner /> }\n\t\t</>\n\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t);\n\n\t// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0\n\t// So we try using the imageRef width first and fallback to clientWidth.\n\tconst fallbackClientWidth = imageRef.current?.width || clientWidth;\n\n\tif ( canEditImage && isEditingImage ) {\n\t\timg = (\n\t\t\t<ImageEditor\n\t\t\t\tid={ id }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ numericWidth }\n\t\t\t\theight={ numericHeight }\n\t\t\t\tclientWidth={ fallbackClientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t\tonSaveImage={ ( imageAttributes ) =>\n\t\t\t\t\tsetAttributes( imageAttributes )\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\tborderProps={ isRounded ? undefined : borderProps }\n\t\t\t/>\n\t\t);\n\t} else if ( ! isResizable ) {\n\t\timg = <div style={ { width, height, aspectRatio } }>{ img }</div>;\n\t} else {\n\t\tconst numericRatio = aspectRatio && evalAspectRatio( aspectRatio );\n\t\tconst customRatio = numericWidth / numericHeight;\n\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\tconst ratio = numericRatio || customRatio || naturalRatio || 1;\n\t\tconst currentWidth =\n\t\t\t! numericWidth && numericHeight\n\t\t\t\t? numericHeight * ratio\n\t\t\t\t: numericWidth;\n\t\tconst currentHeight =\n\t\t\t! numericHeight && numericWidth\n\t\t\t\t? numericWidth / ratio\n\t\t\t\t: numericHeight;\n\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\n\t\timg = (\n\t\t\t<ResizableBox\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'block',\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! width && ! height && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} }\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: currentWidth ?? 'auto',\n\t\t\t\t\theight: currentHeight ?? 'auto',\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={ ratio }\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 ) => {\n\t\t\t\t\tonResizeStop();\n\t\t\t\t\t// Since the aspect ratio is locked when resizing, we can\n\t\t\t\t\t// use the width of the resized element to calculate the\n\t\t\t\t\t// height in CSS to prevent stretching when the max-width\n\t\t\t\t\t// is reached.\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: `${ elt.offsetWidth }px`,\n\t\t\t\t\t\theight: 'auto',\n\t\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t\tratio === naturalRatio\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: String( ratio ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t>\n\t\t\t\t{ img }\n\t\t\t</ResizableBox>\n\t\t);\n\t}\n\n\tif ( ! url && ! temporaryURL ) {\n\t\treturn sizeControls;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Hide controls during upload to avoid component remount,\n\t\t\t\twhich causes duplicated image upload. */ }\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ img }\n\t\t\t{ showCaption &&\n\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Image caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,YAAY,EACZC,YAAY,EACZC,OAAO,EACPC,eAAe,EACfC,aAAa,EACbC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,EAC9CC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,oBAAoB;AAClE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,6BAA6B,IAAIC,eAAe,EAChDC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,UAAU,EACVC,qBAAqB,EACrBC,yBAAyB,IAAIC,WAAW,EACxCC,iCAAiC,EACjCC,4BAA4B,IAAIC,cAAc,EAC9CC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SACCC,SAAS,EACTC,OAAO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C,mBAAmB,CAAC,CAAE,CACpC;EACA,CACD,CAEF,CAAC;AAEL"}
@@ -199,7 +199,17 @@ store({
199
199
  roleAttribute: ({
200
200
  context
201
201
  }) => {
202
- return context.core.image.lightboxEnabled ? 'dialog' : '';
202
+ return context.core.image.lightboxEnabled ? 'dialog' : null;
203
+ },
204
+ ariaModal: ({
205
+ context
206
+ }) => {
207
+ return context.core.image.lightboxEnabled ? 'true' : null;
208
+ },
209
+ dialogLabel: ({
210
+ context
211
+ }) => {
212
+ return context.core.image.lightboxEnabled ? context.core.image.dialogLabel : null;
203
213
  },
204
214
  lightboxObjectFit: ({
205
215
  context
@@ -211,7 +221,7 @@ store({
211
221
  enlargedImgSrc: ({
212
222
  context
213
223
  }) => {
214
- return context.core.image.initialized ? context.core.image.imageUploadedSrc : '';
224
+ return context.core.image.initialized ? context.core.image.imageUploadedSrc : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
215
225
  }
216
226
  }
217
227
  }
@@ -322,11 +332,11 @@ function setStyles(context, event) {
322
332
  naturalHeight,
323
333
  offsetWidth: originalWidth,
324
334
  offsetHeight: originalHeight
325
- } = event.target.nextElementSibling;
335
+ } = event.target.previousElementSibling;
326
336
  let {
327
337
  x: screenPosX,
328
338
  y: screenPosY
329
- } = event.target.nextElementSibling.getBoundingClientRect();
339
+ } = event.target.previousElementSibling.getBoundingClientRect();
330
340
 
331
341
  // Natural ratio of the image clicked to open the lightbox.
332
342
  const naturalRatio = naturalWidth / naturalHeight;
@@ -1 +1 @@
1
- {"version":3,"names":["store","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","context","Date","now","window","scrollTo","core","image","scrollLeftReset","scrollTopReset","state","windowWidth","innerWidth","windowHeight","innerHeight","actions","showLightbox","event","imageLoaded","initialized","lastFocusedElement","document","activeElement","scrollDelta","lightboxEnabled","setStyles","pageYOffset","documentElement","scrollTop","pageXOffset","scrollLeft","bind","addEventListener","hideLightbox","hideAnimationEnabled","setTimeout","removeEventListener","focus","preventScroll","handleKeydown","key","keyCode","shiftKey","firstFocusableElement","preventDefault","lastFocusableElement","handleLoad","effects","ref","imageCurrentSrc","currentSrc","setButtonStyles","handleTouchStart","handleTouchMove","handleTouchEnd","selectors","roleAttribute","lightboxObjectFit","enlargedImgSrc","imageUploadedSrc","setCurrentSrc","complete","initLightbox","figureRef","querySelector","imageRef","focusableElements","querySelectorAll","length","naturalWidth","naturalHeight","offsetWidth","offsetHeight","scaleAttr","naturalRatio","offsetRatio","imageButtonWidth","buttonHeight","imageButtonHeight","imageButtonTop","buttonWidth","imageButtonLeft","afterLoad","debounce","originalWidth","originalHeight","target","nextElementSibling","x","screenPosX","y","screenPosY","getBoundingClientRect","originalRatio","heightWithoutSpace","widthWithoutSpace","imgMaxWidth","parseFloat","targetWidth","imgMaxHeight","targetHeight","imgRatio","containerMaxWidth","containerMaxHeight","containerWidth","containerHeight","toFixed","reducedHeight","reducedWidth","horizontalPadding","verticalPadding","targetMaxWidth","Math","min","targetMaxHeight","targetContainerRatio","containerScale","lightboxImgWidth","lightboxImgHeight","styleTag","getElementById","createElement","id","head","appendChild","innerHTML","func","wait","timeout","later","clearTimeout"],"sources":["@wordpress/block-library/src/image/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'area[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n/*\n * Stores a context-bound scroll handler.\n *\n * This callback could be defined inline inside of the store\n * object but it's created externally to avoid confusion about\n * how its logic is called. This logic is not referenced directly\n * by the directives in the markup because the scroll event we\n * need to listen to is triggered on the window; so by defining it\n * outside of the store, we signal that the behavior here is different.\n * If we find a compelling reason to move it to the store, feel free.\n *\n * @type {Function}\n */\nlet scrollCallback;\n\n/*\n * Tracks whether user is touching screen; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/*\n * Tracks the last time the screen was touched; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\n/*\n * Lightbox page-scroll handler: prevents scrolling.\n *\n * This handler is added to prevent scrolling behaviors that\n * trigger content shift while the lightbox is open.\n *\n * It would be better to accomplish this through CSS alone, but\n * using overflow: hidden is currently the only way to do so, and\n * that causes the layout to shift and prevents the zoom animation\n * from working in some cases because we're unable to account for\n * the layout shift when doing the animation calculations. Instead,\n * here we use JavaScript to prevent and reset the scrolling\n * behavior. In the future, we may be able to use CSS or overflow: hidden\n * instead to not rely on JavaScript, but this seems to be the best approach\n * for now that provides the best visual experience.\n *\n * @param {Object} context Interactivity page context?\n */\nfunction handleScroll( context ) {\n\t// We can't override the scroll behavior on mobile devices\n\t// because doing so breaks the pinch to zoom functionality, and we\n\t// want to allow users to zoom in further on the high-res image.\n\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t// We are unable to use event.preventDefault() to prevent scrolling\n\t\t// because the scroll event can't be canceled, so we reset the position instead.\n\t\twindow.scrollTo(\n\t\t\tcontext.core.image.scrollLeftReset,\n\t\t\tcontext.core.image.scrollTopReset\n\t\t);\n\t}\n}\n\nstore(\n\t{\n\t\tstate: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\twindowWidth: window.innerWidth,\n\t\t\t\t\twindowHeight: window.innerHeight,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tshowLightbox: ( { context, event } ) => {\n\t\t\t\t\t\t// We can't initialize the lightbox until the reference\n\t\t\t\t\t\t// image is loaded, otherwise the UX is broken.\n\t\t\t\t\t\tif ( ! context.core.image.imageLoaded ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontext.core.image.initialized = true;\n\t\t\t\t\t\tcontext.core.image.lastFocusedElement =\n\t\t\t\t\t\t\twindow.document.activeElement;\n\t\t\t\t\t\tcontext.core.image.scrollDelta = 0;\n\n\t\t\t\t\t\tcontext.core.image.lightboxEnabled = true;\n\t\t\t\t\t\tsetStyles( context, event );\n\n\t\t\t\t\t\tcontext.core.image.scrollTopReset =\n\t\t\t\t\t\t\twindow.pageYOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollTop;\n\n\t\t\t\t\t\t// In most cases, this value will be 0, but this is included\n\t\t\t\t\t\t// in case a user has created a page with horizontal scrolling.\n\t\t\t\t\t\tcontext.core.image.scrollLeftReset =\n\t\t\t\t\t\t\twindow.pageXOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollLeft;\n\n\t\t\t\t\t\t// We define and bind the scroll callback here so\n\t\t\t\t\t\t// that we can pass the context and as an argument.\n\t\t\t\t\t\t// We may be able to change this in the future if we\n\t\t\t\t\t\t// define the scroll callback in the store instead, but\n\t\t\t\t\t\t// this approach seems to tbe clearest for now.\n\t\t\t\t\t\tscrollCallback = handleScroll.bind( null, context );\n\n\t\t\t\t\t\t// We need to add a scroll event listener to the window\n\t\t\t\t\t\t// here because we are unable to otherwise access it via\n\t\t\t\t\t\t// the Interactivity API directives. If we add a native way\n\t\t\t\t\t\t// to access the window, we can remove this.\n\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\tscrollCallback,\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\thideLightbox: async ( { context } ) => {\n\t\t\t\t\t\tcontext.core.image.hideAnimationEnabled = true;\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\t// We want to wait until the close animation is completed\n\t\t\t\t\t\t\t// before allowing a user to scroll again. The duration of this\n\t\t\t\t\t\t\t// animation is defined in the styles.scss and depends on if the\n\t\t\t\t\t\t\t// animation is 'zoom' or 'fade', but in any case we should wait\n\t\t\t\t\t\t\t// a few milliseconds longer than the duration, otherwise a user\n\t\t\t\t\t\t\t// may scroll too soon and cause the animation to look sloppy.\n\t\t\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t\t\twindow.removeEventListener(\n\t\t\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\t\t\tscrollCallback\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}, 450 );\n\n\t\t\t\t\t\t\tcontext.core.image.lightboxEnabled = false;\n\t\t\t\t\t\t\tcontext.core.image.lastFocusedElement.focus( {\n\t\t\t\t\t\t\t\tpreventScroll: true,\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\thandleKeydown: ( { context, actions, event } ) => {\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tif ( event.key === 'Tab' || event.keyCode === 9 ) {\n\t\t\t\t\t\t\t\t// If shift + tab it change the direction\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement.focus();\n\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement.focus();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.key === 'Escape' ||\n\t\t\t\t\t\t\t\tevent.keyCode === 27\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tactions.core.image.hideLightbox( {\n\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\tevent,\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\thandleLoad: ( { state, context, effects, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\teffects.core.image.setButtonStyles( {\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchStart: () => {\n\t\t\t\t\t\tisTouching = true;\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchMove: ( { context, event } ) => {\n\t\t\t\t\t\t// On mobile devices, we want to prevent triggering the\n\t\t\t\t\t\t// scroll event because otherwise the page jumps around as\n\t\t\t\t\t\t// we reset the scroll position. This also means that closing\n\t\t\t\t\t\t// the lightbox requires that a user perform a simple tap. This\n\t\t\t\t\t\t// may be changed in the future if we find a better alternative\n\t\t\t\t\t\t// to override or reset the scroll position during swipe actions.\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchEnd: () => {\n\t\t\t\t\t\t// We need to wait a few milliseconds before resetting\n\t\t\t\t\t\t// to ensure that pinch to zoom works consistently\n\t\t\t\t\t\t// on mobile devices when the lightbox is open.\n\t\t\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\t\t\tisTouching = false;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tselectors: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\troleAttribute: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t\t: '';\n\t\t\t\t\t},\n\t\t\t\t\tlightboxObjectFit: ( { context } ) => {\n\t\t\t\t\t\tif ( context.core.image.initialized ) {\n\t\t\t\t\t\t\treturn 'cover';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tenlargedImgSrc: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.initialized\n\t\t\t\t\t\t\t? context.core.image.imageUploadedSrc\n\t\t\t\t\t\t\t: '';\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\teffects: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tsetCurrentSrc: ( { context, ref } ) => {\n\t\t\t\t\t\tif ( ref.complete ) {\n\t\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tinitLightbox: async ( { context, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.figureRef =\n\t\t\t\t\t\t\tref.querySelector( 'figure' );\n\t\t\t\t\t\tcontext.core.image.imageRef =\n\t\t\t\t\t\t\tref.querySelector( 'img' );\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[\n\t\t\t\t\t\t\t\t\tfocusableElements.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tref.querySelector( '.close-button' ).focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tsetButtonStyles: ( { state, context, ref } ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tnaturalWidth,\n\t\t\t\t\t\t\tnaturalHeight,\n\t\t\t\t\t\t\toffsetWidth,\n\t\t\t\t\t\t\toffsetHeight,\n\t\t\t\t\t\t} = ref;\n\n\t\t\t\t\t\t// If the image isn't loaded yet, we can't\n\t\t\t\t\t\t// calculate how big the button should be.\n\t\t\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Subscribe to the window dimensions so we can\n\t\t\t\t\t\t// recalculate the styles if the window is resized.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t( state.core.image.windowWidth ||\n\t\t\t\t\t\t\t\tstate.core.image.windowHeight ) &&\n\t\t\t\t\t\t\tcontext.core.image.scaleAttr === 'contain'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// In the case of an image with object-fit: contain, the\n\t\t\t\t\t\t\t// size of the img element can be larger than the image itself,\n\t\t\t\t\t\t\t// so we need to calculate the size of the button to match.\n\n\t\t\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\t\t\tif ( naturalRatio > offsetRatio ) {\n\t\t\t\t\t\t\t\t// If it reaches the width first, keep\n\t\t\t\t\t\t\t\t// the width and recalculate the height.\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonWidth =\n\t\t\t\t\t\t\t\t\toffsetWidth;\n\t\t\t\t\t\t\t\tconst buttonHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonHeight =\n\t\t\t\t\t\t\t\t\tbuttonHeight;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\t\t( offsetHeight - buttonHeight ) / 2;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If it reaches the height first, keep\n\t\t\t\t\t\t\t\t// the height and recalculate the width.\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonHeight =\n\t\t\t\t\t\t\t\t\toffsetHeight;\n\t\t\t\t\t\t\t\tconst buttonWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonWidth =\n\t\t\t\t\t\t\t\t\tbuttonWidth;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonLeft =\n\t\t\t\t\t\t\t\t\t( offsetWidth - buttonWidth ) / 2;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// In all other cases, we can trust that the size of\n\t\t\t\t\t\t\t// the image is the right size for the button as well.\n\n\t\t\t\t\t\t\tcontext.core.image.imageButtonWidth = offsetWidth;\n\t\t\t\t\t\t\tcontext.core.image.imageButtonHeight = offsetHeight;\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},\n\t},\n\t{\n\t\tafterLoad: ( { state } ) => {\n\t\t\twindow.addEventListener(\n\t\t\t\t'resize',\n\t\t\t\tdebounce( () => {\n\t\t\t\t\tstate.core.image.windowWidth = window.innerWidth;\n\t\t\t\t\tstate.core.image.windowHeight = window.innerHeight;\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t}\n);\n\n/*\n * Computes styles for the lightbox and adds them to the document.\n *\n * @function\n * @param {Object} context - An Interactivity API context\n * @param {Object} event - A triggering event\n */\nfunction setStyles( context, event ) {\n\t// The reference img element lies adjacent\n\t// to the event target button in the DOM.\n\tlet {\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\toffsetWidth: originalWidth,\n\t\toffsetHeight: originalHeight,\n\t} = event.target.nextElementSibling;\n\tlet { x: screenPosX, y: screenPosY } =\n\t\tevent.target.nextElementSibling.getBoundingClientRect();\n\n\t// Natural ratio of the image clicked to open the lightbox.\n\tconst naturalRatio = naturalWidth / naturalHeight;\n\t// Original ratio of the image clicked to open the lightbox.\n\tlet originalRatio = originalWidth / originalHeight;\n\n\t// If it has object-fit: contain, recalculate the original sizes\n\t// and the screen position without the blank spaces.\n\tif ( context.core.image.scaleAttr === 'contain' ) {\n\t\tif ( naturalRatio > originalRatio ) {\n\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t// Recalculate screen position without the top space.\n\t\t\tscreenPosY += ( originalHeight - heightWithoutSpace ) / 2;\n\t\t\toriginalHeight = heightWithoutSpace;\n\t\t} else {\n\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t// Recalculate screen position without the left space.\n\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\toriginalWidth = widthWithoutSpace;\n\t\t}\n\t}\n\toriginalRatio = originalWidth / originalHeight;\n\n\t// Typically, we use the image's full-sized dimensions. If those\n\t// dimensions have not been set (i.e. an external image with only one size),\n\t// the image's dimensions in the lightbox are the same\n\t// as those of the image in the content.\n\tlet imgMaxWidth = parseFloat(\n\t\tcontext.core.image.targetWidth !== 'none'\n\t\t\t? context.core.image.targetWidth\n\t\t\t: naturalWidth\n\t);\n\tlet imgMaxHeight = parseFloat(\n\t\tcontext.core.image.targetHeight !== 'none'\n\t\t\t? context.core.image.targetHeight\n\t\t\t: naturalHeight\n\t);\n\n\t// Ratio of the biggest image stored in the database.\n\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\tlet containerMaxWidth = imgMaxWidth;\n\tlet containerMaxHeight = imgMaxHeight;\n\tlet containerWidth = imgMaxWidth;\n\tlet containerHeight = imgMaxHeight;\n\t// Check if the target image has a different ratio than the original one (thumbnail).\n\t// Recalculate the width and height.\n\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t// If the width is reached before the height, we keep the maxWidth\n\t\t\t// and recalculate the height.\n\t\t\t// Unless the difference between the maxHeight and the reducedHeight\n\t\t\t// is higher than the maxWidth, where we keep the reducedHeight and\n\t\t\t// recalculate the width.\n\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t}\n\t\t} else {\n\t\t\t// If the height is reached before the width, we keep the maxHeight\n\t\t\t// and recalculate the width.\n\t\t\t// Unless the difference between the maxWidth and the reducedWidth\n\t\t\t// is higher than the maxHeight, where we keep the reducedWidth and\n\t\t\t// recalculate the height.\n\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t}\n\t\t}\n\t\tcontainerWidth = imgMaxWidth;\n\t\tcontainerHeight = imgMaxHeight;\n\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t// Calculate the max size of the container.\n\t\tif ( originalRatio > imgRatio ) {\n\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t} else {\n\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t}\n\t}\n\n\t// If the image has been pixelated on purpose, keep that size.\n\tif ( originalWidth > containerWidth || originalHeight > containerHeight ) {\n\t\tcontainerWidth = originalWidth;\n\t\tcontainerHeight = originalHeight;\n\t}\n\n\t// Calculate the final lightbox image size and the\n\t// scale factor. MaxWidth is either the window container\n\t// (accounting for padding) or the image resolution.\n\tlet horizontalPadding = 0;\n\tif ( window.innerWidth > 480 ) {\n\t\thorizontalPadding = 80;\n\t} else if ( window.innerWidth > 1920 ) {\n\t\thorizontalPadding = 160;\n\t}\n\tconst verticalPadding = 80;\n\n\tconst targetMaxWidth = Math.min(\n\t\twindow.innerWidth - horizontalPadding,\n\t\tcontainerWidth\n\t);\n\tconst targetMaxHeight = Math.min(\n\t\twindow.innerHeight - verticalPadding,\n\t\tcontainerHeight\n\t);\n\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\tif ( originalRatio > targetContainerRatio ) {\n\t\t// If targetMaxWidth is reached before targetMaxHeight\n\t\tcontainerWidth = targetMaxWidth;\n\t\tcontainerHeight = containerWidth / originalRatio;\n\t} else {\n\t\t// If targetMaxHeight is reached before targetMaxWidth\n\t\tcontainerHeight = targetMaxHeight;\n\t\tcontainerWidth = containerHeight * originalRatio;\n\t}\n\n\tconst containerScale = originalWidth / containerWidth;\n\tconst lightboxImgWidth =\n\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\tconst lightboxImgHeight =\n\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t// Add the CSS variables needed.\n\tlet styleTag = document.getElementById( 'wp-lightbox-styles' );\n\tif ( ! styleTag ) {\n\t\tstyleTag = document.createElement( 'style' );\n\t\tstyleTag.id = 'wp-lightbox-styles';\n\t\tdocument.head.appendChild( styleTag );\n\t}\n\n\t// As of this writing, using the calculations above will render the lightbox\n\t// with a small, erroneous whitespace on the left side of the image in iOS Safari,\n\t// perhaps due to an inconsistency in how browsers handle absolute positioning and CSS\n\t// transformation. In any case, adding 1 pixel to the container width and height solves\n\t// the problem, though this can be removed if the issue is fixed in the future.\n\tstyleTag.innerHTML = `\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t}\n\t`;\n}\n\n/*\n * Debounces a function call.\n *\n * @function\n * @param {Function} func - A function to be called\n * @param {number} wait - The time to wait before calling the function\n */\nfunction debounce( func, wait = 50 ) {\n\tlet timeout;\n\treturn () => {\n\t\tconst later = () => {\n\t\t\ttimeout = null;\n\t\t\tfunc();\n\t\t};\n\t\tclearTimeout( timeout );\n\t\ttimeout = setTimeout( later, wait );\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAEhD,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,YAAY,EACZ,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,iCAAiC,CACjC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,cAAc;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,UAAU,GAAG,KAAK;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,aAAa,GAAG,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAAEC,OAAO,EAAG;EAChC;EACA;EACA;EACA,IAAK,CAAEH,UAAU,IAAII,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGJ,aAAa,GAAG,GAAG,EAAG;IACvD;IACA;IACAK,MAAM,CAACC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jC,QAAQA,CAAE2C,IAAI,EAAEC,IAAI,GAAG,EAAE,EAAG;EACpC,IAAIC,OAAO;EACX,OAAO,MAAM;IACZ,MAAMC,KAAK,GAAGA,CAAA,KAAM;MACnBD,OAAO,GAAG,IAAI;MACdF,IAAI,CAAC,CAAC;IACP,CAAC;IACDI,YAAY,CAAEF,OAAQ,CAAC;IACvBA,OAAO,GAAG7F,UAAU,CAAE8F,KAAK,EAAEF,IAAK,CAAC;EACpC,CAAC;AACF"}
1
+ {"version":3,"names":["store","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","context","Date","now","window","scrollTo","core","image","scrollLeftReset","scrollTopReset","state","windowWidth","innerWidth","windowHeight","innerHeight","actions","showLightbox","event","imageLoaded","initialized","lastFocusedElement","document","activeElement","scrollDelta","lightboxEnabled","setStyles","pageYOffset","documentElement","scrollTop","pageXOffset","scrollLeft","bind","addEventListener","hideLightbox","hideAnimationEnabled","setTimeout","removeEventListener","focus","preventScroll","handleKeydown","key","keyCode","shiftKey","firstFocusableElement","preventDefault","lastFocusableElement","handleLoad","effects","ref","imageCurrentSrc","currentSrc","setButtonStyles","handleTouchStart","handleTouchMove","handleTouchEnd","selectors","roleAttribute","ariaModal","dialogLabel","lightboxObjectFit","enlargedImgSrc","imageUploadedSrc","setCurrentSrc","complete","initLightbox","figureRef","querySelector","imageRef","focusableElements","querySelectorAll","length","naturalWidth","naturalHeight","offsetWidth","offsetHeight","scaleAttr","naturalRatio","offsetRatio","imageButtonWidth","buttonHeight","imageButtonHeight","imageButtonTop","buttonWidth","imageButtonLeft","afterLoad","debounce","originalWidth","originalHeight","target","previousElementSibling","x","screenPosX","y","screenPosY","getBoundingClientRect","originalRatio","heightWithoutSpace","widthWithoutSpace","imgMaxWidth","parseFloat","targetWidth","imgMaxHeight","targetHeight","imgRatio","containerMaxWidth","containerMaxHeight","containerWidth","containerHeight","toFixed","reducedHeight","reducedWidth","horizontalPadding","verticalPadding","targetMaxWidth","Math","min","targetMaxHeight","targetContainerRatio","containerScale","lightboxImgWidth","lightboxImgHeight","styleTag","getElementById","createElement","id","head","appendChild","innerHTML","func","wait","timeout","later","clearTimeout"],"sources":["@wordpress/block-library/src/image/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'area[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n/*\n * Stores a context-bound scroll handler.\n *\n * This callback could be defined inline inside of the store\n * object but it's created externally to avoid confusion about\n * how its logic is called. This logic is not referenced directly\n * by the directives in the markup because the scroll event we\n * need to listen to is triggered on the window; so by defining it\n * outside of the store, we signal that the behavior here is different.\n * If we find a compelling reason to move it to the store, feel free.\n *\n * @type {Function}\n */\nlet scrollCallback;\n\n/*\n * Tracks whether user is touching screen; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/*\n * Tracks the last time the screen was touched; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\n/*\n * Lightbox page-scroll handler: prevents scrolling.\n *\n * This handler is added to prevent scrolling behaviors that\n * trigger content shift while the lightbox is open.\n *\n * It would be better to accomplish this through CSS alone, but\n * using overflow: hidden is currently the only way to do so, and\n * that causes the layout to shift and prevents the zoom animation\n * from working in some cases because we're unable to account for\n * the layout shift when doing the animation calculations. Instead,\n * here we use JavaScript to prevent and reset the scrolling\n * behavior. In the future, we may be able to use CSS or overflow: hidden\n * instead to not rely on JavaScript, but this seems to be the best approach\n * for now that provides the best visual experience.\n *\n * @param {Object} context Interactivity page context?\n */\nfunction handleScroll( context ) {\n\t// We can't override the scroll behavior on mobile devices\n\t// because doing so breaks the pinch to zoom functionality, and we\n\t// want to allow users to zoom in further on the high-res image.\n\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t// We are unable to use event.preventDefault() to prevent scrolling\n\t\t// because the scroll event can't be canceled, so we reset the position instead.\n\t\twindow.scrollTo(\n\t\t\tcontext.core.image.scrollLeftReset,\n\t\t\tcontext.core.image.scrollTopReset\n\t\t);\n\t}\n}\n\nstore(\n\t{\n\t\tstate: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\twindowWidth: window.innerWidth,\n\t\t\t\t\twindowHeight: window.innerHeight,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tshowLightbox: ( { context, event } ) => {\n\t\t\t\t\t\t// We can't initialize the lightbox until the reference\n\t\t\t\t\t\t// image is loaded, otherwise the UX is broken.\n\t\t\t\t\t\tif ( ! context.core.image.imageLoaded ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontext.core.image.initialized = true;\n\t\t\t\t\t\tcontext.core.image.lastFocusedElement =\n\t\t\t\t\t\t\twindow.document.activeElement;\n\t\t\t\t\t\tcontext.core.image.scrollDelta = 0;\n\n\t\t\t\t\t\tcontext.core.image.lightboxEnabled = true;\n\t\t\t\t\t\tsetStyles( context, event );\n\n\t\t\t\t\t\tcontext.core.image.scrollTopReset =\n\t\t\t\t\t\t\twindow.pageYOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollTop;\n\n\t\t\t\t\t\t// In most cases, this value will be 0, but this is included\n\t\t\t\t\t\t// in case a user has created a page with horizontal scrolling.\n\t\t\t\t\t\tcontext.core.image.scrollLeftReset =\n\t\t\t\t\t\t\twindow.pageXOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollLeft;\n\n\t\t\t\t\t\t// We define and bind the scroll callback here so\n\t\t\t\t\t\t// that we can pass the context and as an argument.\n\t\t\t\t\t\t// We may be able to change this in the future if we\n\t\t\t\t\t\t// define the scroll callback in the store instead, but\n\t\t\t\t\t\t// this approach seems to tbe clearest for now.\n\t\t\t\t\t\tscrollCallback = handleScroll.bind( null, context );\n\n\t\t\t\t\t\t// We need to add a scroll event listener to the window\n\t\t\t\t\t\t// here because we are unable to otherwise access it via\n\t\t\t\t\t\t// the Interactivity API directives. If we add a native way\n\t\t\t\t\t\t// to access the window, we can remove this.\n\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\tscrollCallback,\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\thideLightbox: async ( { context } ) => {\n\t\t\t\t\t\tcontext.core.image.hideAnimationEnabled = true;\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\t// We want to wait until the close animation is completed\n\t\t\t\t\t\t\t// before allowing a user to scroll again. The duration of this\n\t\t\t\t\t\t\t// animation is defined in the styles.scss and depends on if the\n\t\t\t\t\t\t\t// animation is 'zoom' or 'fade', but in any case we should wait\n\t\t\t\t\t\t\t// a few milliseconds longer than the duration, otherwise a user\n\t\t\t\t\t\t\t// may scroll too soon and cause the animation to look sloppy.\n\t\t\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t\t\twindow.removeEventListener(\n\t\t\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\t\t\tscrollCallback\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}, 450 );\n\n\t\t\t\t\t\t\tcontext.core.image.lightboxEnabled = false;\n\t\t\t\t\t\t\tcontext.core.image.lastFocusedElement.focus( {\n\t\t\t\t\t\t\t\tpreventScroll: true,\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\thandleKeydown: ( { context, actions, event } ) => {\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tif ( event.key === 'Tab' || event.keyCode === 9 ) {\n\t\t\t\t\t\t\t\t// If shift + tab it change the direction\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement.focus();\n\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement.focus();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.key === 'Escape' ||\n\t\t\t\t\t\t\t\tevent.keyCode === 27\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tactions.core.image.hideLightbox( {\n\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\tevent,\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\thandleLoad: ( { state, context, effects, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\teffects.core.image.setButtonStyles( {\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchStart: () => {\n\t\t\t\t\t\tisTouching = true;\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchMove: ( { context, event } ) => {\n\t\t\t\t\t\t// On mobile devices, we want to prevent triggering the\n\t\t\t\t\t\t// scroll event because otherwise the page jumps around as\n\t\t\t\t\t\t// we reset the scroll position. This also means that closing\n\t\t\t\t\t\t// the lightbox requires that a user perform a simple tap. This\n\t\t\t\t\t\t// may be changed in the future if we find a better alternative\n\t\t\t\t\t\t// to override or reset the scroll position during swipe actions.\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchEnd: () => {\n\t\t\t\t\t\t// We need to wait a few milliseconds before resetting\n\t\t\t\t\t\t// to ensure that pinch to zoom works consistently\n\t\t\t\t\t\t// on mobile devices when the lightbox is open.\n\t\t\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\t\t\tisTouching = false;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tselectors: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\troleAttribute: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tariaModal: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tdialogLabel: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? context.core.image.dialogLabel\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tlightboxObjectFit: ( { context } ) => {\n\t\t\t\t\t\tif ( context.core.image.initialized ) {\n\t\t\t\t\t\t\treturn 'cover';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tenlargedImgSrc: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.initialized\n\t\t\t\t\t\t\t? context.core.image.imageUploadedSrc\n\t\t\t\t\t\t\t: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\teffects: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tsetCurrentSrc: ( { context, ref } ) => {\n\t\t\t\t\t\tif ( ref.complete ) {\n\t\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tinitLightbox: async ( { context, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.figureRef =\n\t\t\t\t\t\t\tref.querySelector( 'figure' );\n\t\t\t\t\t\tcontext.core.image.imageRef =\n\t\t\t\t\t\t\tref.querySelector( 'img' );\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[\n\t\t\t\t\t\t\t\t\tfocusableElements.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tref.querySelector( '.close-button' ).focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tsetButtonStyles: ( { state, context, ref } ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tnaturalWidth,\n\t\t\t\t\t\t\tnaturalHeight,\n\t\t\t\t\t\t\toffsetWidth,\n\t\t\t\t\t\t\toffsetHeight,\n\t\t\t\t\t\t} = ref;\n\n\t\t\t\t\t\t// If the image isn't loaded yet, we can't\n\t\t\t\t\t\t// calculate how big the button should be.\n\t\t\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Subscribe to the window dimensions so we can\n\t\t\t\t\t\t// recalculate the styles if the window is resized.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t( state.core.image.windowWidth ||\n\t\t\t\t\t\t\t\tstate.core.image.windowHeight ) &&\n\t\t\t\t\t\t\tcontext.core.image.scaleAttr === 'contain'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// In the case of an image with object-fit: contain, the\n\t\t\t\t\t\t\t// size of the img element can be larger than the image itself,\n\t\t\t\t\t\t\t// so we need to calculate the size of the button to match.\n\n\t\t\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\t\t\tif ( naturalRatio > offsetRatio ) {\n\t\t\t\t\t\t\t\t// If it reaches the width first, keep\n\t\t\t\t\t\t\t\t// the width and recalculate the height.\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonWidth =\n\t\t\t\t\t\t\t\t\toffsetWidth;\n\t\t\t\t\t\t\t\tconst buttonHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonHeight =\n\t\t\t\t\t\t\t\t\tbuttonHeight;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\t\t( offsetHeight - buttonHeight ) / 2;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If it reaches the height first, keep\n\t\t\t\t\t\t\t\t// the height and recalculate the width.\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonHeight =\n\t\t\t\t\t\t\t\t\toffsetHeight;\n\t\t\t\t\t\t\t\tconst buttonWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonWidth =\n\t\t\t\t\t\t\t\t\tbuttonWidth;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonLeft =\n\t\t\t\t\t\t\t\t\t( offsetWidth - buttonWidth ) / 2;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// In all other cases, we can trust that the size of\n\t\t\t\t\t\t\t// the image is the right size for the button as well.\n\n\t\t\t\t\t\t\tcontext.core.image.imageButtonWidth = offsetWidth;\n\t\t\t\t\t\t\tcontext.core.image.imageButtonHeight = offsetHeight;\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},\n\t},\n\t{\n\t\tafterLoad: ( { state } ) => {\n\t\t\twindow.addEventListener(\n\t\t\t\t'resize',\n\t\t\t\tdebounce( () => {\n\t\t\t\t\tstate.core.image.windowWidth = window.innerWidth;\n\t\t\t\t\tstate.core.image.windowHeight = window.innerHeight;\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t}\n);\n\n/*\n * Computes styles for the lightbox and adds them to the document.\n *\n * @function\n * @param {Object} context - An Interactivity API context\n * @param {Object} event - A triggering event\n */\nfunction setStyles( context, event ) {\n\t// The reference img element lies adjacent\n\t// to the event target button in the DOM.\n\tlet {\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\toffsetWidth: originalWidth,\n\t\toffsetHeight: originalHeight,\n\t} = event.target.previousElementSibling;\n\tlet { x: screenPosX, y: screenPosY } =\n\t\tevent.target.previousElementSibling.getBoundingClientRect();\n\n\t// Natural ratio of the image clicked to open the lightbox.\n\tconst naturalRatio = naturalWidth / naturalHeight;\n\t// Original ratio of the image clicked to open the lightbox.\n\tlet originalRatio = originalWidth / originalHeight;\n\n\t// If it has object-fit: contain, recalculate the original sizes\n\t// and the screen position without the blank spaces.\n\tif ( context.core.image.scaleAttr === 'contain' ) {\n\t\tif ( naturalRatio > originalRatio ) {\n\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t// Recalculate screen position without the top space.\n\t\t\tscreenPosY += ( originalHeight - heightWithoutSpace ) / 2;\n\t\t\toriginalHeight = heightWithoutSpace;\n\t\t} else {\n\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t// Recalculate screen position without the left space.\n\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\toriginalWidth = widthWithoutSpace;\n\t\t}\n\t}\n\toriginalRatio = originalWidth / originalHeight;\n\n\t// Typically, we use the image's full-sized dimensions. If those\n\t// dimensions have not been set (i.e. an external image with only one size),\n\t// the image's dimensions in the lightbox are the same\n\t// as those of the image in the content.\n\tlet imgMaxWidth = parseFloat(\n\t\tcontext.core.image.targetWidth !== 'none'\n\t\t\t? context.core.image.targetWidth\n\t\t\t: naturalWidth\n\t);\n\tlet imgMaxHeight = parseFloat(\n\t\tcontext.core.image.targetHeight !== 'none'\n\t\t\t? context.core.image.targetHeight\n\t\t\t: naturalHeight\n\t);\n\n\t// Ratio of the biggest image stored in the database.\n\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\tlet containerMaxWidth = imgMaxWidth;\n\tlet containerMaxHeight = imgMaxHeight;\n\tlet containerWidth = imgMaxWidth;\n\tlet containerHeight = imgMaxHeight;\n\t// Check if the target image has a different ratio than the original one (thumbnail).\n\t// Recalculate the width and height.\n\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t// If the width is reached before the height, we keep the maxWidth\n\t\t\t// and recalculate the height.\n\t\t\t// Unless the difference between the maxHeight and the reducedHeight\n\t\t\t// is higher than the maxWidth, where we keep the reducedHeight and\n\t\t\t// recalculate the width.\n\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t}\n\t\t} else {\n\t\t\t// If the height is reached before the width, we keep the maxHeight\n\t\t\t// and recalculate the width.\n\t\t\t// Unless the difference between the maxWidth and the reducedWidth\n\t\t\t// is higher than the maxHeight, where we keep the reducedWidth and\n\t\t\t// recalculate the height.\n\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t}\n\t\t}\n\t\tcontainerWidth = imgMaxWidth;\n\t\tcontainerHeight = imgMaxHeight;\n\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t// Calculate the max size of the container.\n\t\tif ( originalRatio > imgRatio ) {\n\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t} else {\n\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t}\n\t}\n\n\t// If the image has been pixelated on purpose, keep that size.\n\tif ( originalWidth > containerWidth || originalHeight > containerHeight ) {\n\t\tcontainerWidth = originalWidth;\n\t\tcontainerHeight = originalHeight;\n\t}\n\n\t// Calculate the final lightbox image size and the\n\t// scale factor. MaxWidth is either the window container\n\t// (accounting for padding) or the image resolution.\n\tlet horizontalPadding = 0;\n\tif ( window.innerWidth > 480 ) {\n\t\thorizontalPadding = 80;\n\t} else if ( window.innerWidth > 1920 ) {\n\t\thorizontalPadding = 160;\n\t}\n\tconst verticalPadding = 80;\n\n\tconst targetMaxWidth = Math.min(\n\t\twindow.innerWidth - horizontalPadding,\n\t\tcontainerWidth\n\t);\n\tconst targetMaxHeight = Math.min(\n\t\twindow.innerHeight - verticalPadding,\n\t\tcontainerHeight\n\t);\n\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\tif ( originalRatio > targetContainerRatio ) {\n\t\t// If targetMaxWidth is reached before targetMaxHeight\n\t\tcontainerWidth = targetMaxWidth;\n\t\tcontainerHeight = containerWidth / originalRatio;\n\t} else {\n\t\t// If targetMaxHeight is reached before targetMaxWidth\n\t\tcontainerHeight = targetMaxHeight;\n\t\tcontainerWidth = containerHeight * originalRatio;\n\t}\n\n\tconst containerScale = originalWidth / containerWidth;\n\tconst lightboxImgWidth =\n\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\tconst lightboxImgHeight =\n\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t// Add the CSS variables needed.\n\tlet styleTag = document.getElementById( 'wp-lightbox-styles' );\n\tif ( ! styleTag ) {\n\t\tstyleTag = document.createElement( 'style' );\n\t\tstyleTag.id = 'wp-lightbox-styles';\n\t\tdocument.head.appendChild( styleTag );\n\t}\n\n\t// As of this writing, using the calculations above will render the lightbox\n\t// with a small, erroneous whitespace on the left side of the image in iOS Safari,\n\t// perhaps due to an inconsistency in how browsers handle absolute positioning and CSS\n\t// transformation. In any case, adding 1 pixel to the container width and height solves\n\t// the problem, though this can be removed if the issue is fixed in the future.\n\tstyleTag.innerHTML = `\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t}\n\t`;\n}\n\n/*\n * Debounces a function call.\n *\n * @function\n * @param {Function} func - A function to be called\n * @param {number} wait - The time to wait before calling the function\n */\nfunction debounce( func, wait = 50 ) {\n\tlet timeout;\n\treturn () => {\n\t\tconst later = () => {\n\t\t\ttimeout = null;\n\t\t\tfunc();\n\t\t};\n\t\tclearTimeout( timeout );\n\t\ttimeout = setTimeout( later, wait );\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAEhD,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,YAAY,EACZ,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,iCAAiC,CACjC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,cAAc;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,UAAU,GAAG,KAAK;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,aAAa,GAAG,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAAEC,OAAO,EAAG;EAChC;EACA;EACA;EACA,IAAK,CAAEH,UAAU,IAAII,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGJ,aAAa,GAAG,GAAG,EAAG;IACvD;IACA;IACAK,MAAM,CAACC,QAAQ,CACdJ,OAAO,CAACK,IAAI,CAACC,KAAK,CAACC,eAAe,EAClCP,OAAO,CAACK,IAAI,CAACC,KAAK,CAACE,cACpB,CAAC;EACF;AACD;AAEAd,KAAK,CACJ;EACCe,KAAK,EAAE;IACNJ,IAAI,EAAE;MACLC,KAAK,EAAE;QACNI,WAAW,EAAEP,MAAM,CAACQ,UAAU;QAC9BC,YAAY,EAAET,MAAM,CAACU;MACtB;IACD;EACD,CAAC;EACDC,OAAO,EAAE;I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;AACA;AACA;AACA;AACA;AACA,SAASjC,QAAQA,CAAE2C,IAAI,EAAEC,IAAI,GAAG,EAAE,EAAG;EACpC,IAAIC,OAAO;EACX,OAAO,MAAM;IACZ,MAAMC,KAAK,GAAGA,CAAA,KAAM;MACnBD,OAAO,GAAG,IAAI;MACdF,IAAI,CAAC,CAAC;IACP,CAAC;IACDI,YAAY,CAAEF,OAAQ,CAAC;IACvBA,OAAO,GAAG/F,UAAU,CAAEgG,KAAK,EAAEF,IAAK,CAAC;EACpC,CAAC;AACF"}
@@ -346,14 +346,18 @@ export default function LatestPostsEdit({
346
346
  }
347
347
  });
348
348
  const needsReadMore = excerptLength < excerpt.trim().split(' ').length && post.excerpt.raw === '';
349
- const postExcerpt = needsReadMore ? createElement(Fragment, null, excerpt.trim().split(' ', excerptLength).join(' '), createInterpolateElement( /* translators: excerpt truncation character, default */
350
- __(' … <a>Read more</a>'), {
349
+ const postExcerpt = needsReadMore ? createElement(Fragment, null, excerpt.trim().split(' ', excerptLength).join(' '), createInterpolateElement(sprintf( /* translators: 1: The static string "Read more", 2: The post title only visible to screen readers. */
350
+ __('… <a>%1$s<span>: %2$s</span></a>'), __('Read more'), titleTrimmed || __('(no title)')), {
351
351
  a:
352
352
  // eslint-disable-next-line jsx-a11y/anchor-has-content
353
353
  createElement("a", {
354
+ className: "wp-block-latest-posts__read-more",
354
355
  href: post.link,
355
356
  rel: "noopener noreferrer",
356
357
  onClick: showRedirectionPreventedNotice
358
+ }),
359
+ span: createElement("span", {
360
+ className: "screen-reader-text"
357
361
  })
358
362
  })) : excerpt;
359
363
  return createElement("li", {