@wordpress/block-library 8.20.1 → 8.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +12 -0
- package/build/block/index.js +2 -1
- package/build/block/index.js.map +1 -1
- package/build/code/edit.native.js +8 -2
- package/build/code/edit.native.js.map +1 -1
- package/build/cover/deprecated.js +110 -1
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/index.js +9 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -2
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +0 -3
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +2 -1
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +1 -1
- package/build/cover/shared.js.map +1 -1
- package/build/footnotes/index.js +1 -0
- package/build/footnotes/index.js.map +1 -1
- package/build/form/edit.js +138 -0
- package/build/form/edit.js.map +1 -0
- package/build/form/index.js +92 -0
- package/build/form/index.js.map +1 -0
- package/build/form/init.js +13 -0
- package/build/form/init.js.map +1 -0
- package/build/form/save.js +28 -0
- package/build/form/save.js.map +1 -0
- package/build/form/utils.js +24 -0
- package/build/form/utils.js.map +1 -0
- package/build/form/variations.js +95 -0
- package/build/form/variations.js.map +1 -0
- package/build/form/view.js +42 -0
- package/build/form/view.js.map +1 -0
- package/build/form-input/edit.js +124 -0
- package/build/form-input/edit.js.map +1 -0
- package/build/form-input/index.js +105 -0
- package/build/form-input/index.js.map +1 -0
- package/build/form-input/init.js +13 -0
- package/build/form-input/init.js.map +1 -0
- package/build/form-input/save.js +87 -0
- package/build/form-input/save.js.map +1 -0
- package/build/form-input/variations.js +93 -0
- package/build/form-input/variations.js.map +1 -0
- package/build/form-submission-notification/edit.js +59 -0
- package/build/form-submission-notification/edit.js.map +1 -0
- package/build/form-submission-notification/index.js +56 -0
- package/build/form-submission-notification/index.js.map +1 -0
- package/build/form-submission-notification/init.js +13 -0
- package/build/form-submission-notification/init.js.map +1 -0
- package/build/form-submission-notification/save.js +33 -0
- package/build/form-submission-notification/save.js.map +1 -0
- package/build/form-submission-notification/variations.js +63 -0
- package/build/form-submission-notification/variations.js.map +1 -0
- package/build/form-submit-button/edit.js +32 -0
- package/build/form-submit-button/edit.js.map +1 -0
- package/build/form-submit-button/index.js +44 -0
- package/build/form-submit-button/index.js.map +1 -0
- package/build/form-submit-button/init.js +13 -0
- package/build/form-submit-button/init.js.map +1 -0
- package/build/form-submit-button/save.js +22 -0
- package/build/form-submit-button/save.js.map +1 -0
- package/build/group/index.js +0 -1
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +3 -2
- package/build/heading/index.js.map +1 -1
- package/build/image/image.js +4 -1
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +82 -40
- package/build/image/view.js.map +1 -1
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/latest-posts/edit.js +6 -2
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +15 -15
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/missing/edit.native.js +14 -62
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +0 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +2 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +27 -5
- package/build/navigation/view.js.map +1 -1
- package/build/page-list-item/edit.js +3 -1
- package/build/page-list-item/edit.js.map +1 -1
- package/build/paragraph/index.js +7 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/pattern/index.js +2 -1
- package/build/pattern/index.js.map +1 -1
- package/build/template-part/index.js +2 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/block/index.js +2 -1
- package/build-module/block/index.js.map +1 -1
- package/build-module/code/edit.native.js +8 -2
- package/build-module/code/edit.native.js.map +1 -1
- package/build-module/cover/deprecated.js +110 -1
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/index.js +9 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +0 -3
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +2 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +1 -1
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/footnotes/index.js +1 -0
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/form/edit.js +130 -0
- package/build-module/form/edit.js.map +1 -0
- package/build-module/form/index.js +82 -0
- package/build-module/form/index.js.map +1 -0
- package/build-module/form/init.js +6 -0
- package/build-module/form/init.js.map +1 -0
- package/build-module/form/save.js +20 -0
- package/build-module/form/save.js.map +1 -0
- package/build-module/form/utils.js +15 -0
- package/build-module/form/utils.js.map +1 -0
- package/build-module/form/variations.js +86 -0
- package/build-module/form/variations.js.map +1 -0
- package/build-module/form/view.js +40 -0
- package/build-module/form/view.js.map +1 -0
- package/build-module/form-input/edit.js +115 -0
- package/build-module/form-input/edit.js.map +1 -0
- package/build-module/form-input/index.js +95 -0
- package/build-module/form-input/index.js.map +1 -0
- package/build-module/form-input/init.js +6 -0
- package/build-module/form-input/init.js.map +1 -0
- package/build-module/form-input/save.js +80 -0
- package/build-module/form-input/save.js.map +1 -0
- package/build-module/form-input/variations.js +85 -0
- package/build-module/form-input/variations.js.map +1 -0
- package/build-module/form-submission-notification/edit.js +50 -0
- package/build-module/form-submission-notification/edit.js.map +1 -0
- package/build-module/form-submission-notification/index.js +47 -0
- package/build-module/form-submission-notification/index.js.map +1 -0
- package/build-module/form-submission-notification/init.js +6 -0
- package/build-module/form-submission-notification/init.js.map +1 -0
- package/build-module/form-submission-notification/save.js +25 -0
- package/build-module/form-submission-notification/save.js.map +1 -0
- package/build-module/form-submission-notification/variations.js +55 -0
- package/build-module/form-submission-notification/variations.js.map +1 -0
- package/build-module/form-submit-button/edit.js +24 -0
- package/build-module/form-submit-button/edit.js.map +1 -0
- package/build-module/form-submit-button/index.js +34 -0
- package/build-module/form-submit-button/index.js.map +1 -0
- package/build-module/form-submit-button/init.js +6 -0
- package/build-module/form-submit-button/init.js.map +1 -0
- package/build-module/form-submit-button/save.js +14 -0
- package/build-module/form-submit-button/save.js.map +1 -0
- package/build-module/group/index.js +0 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +3 -2
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/image.js +4 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +82 -40
- package/build-module/image/view.js.map +1 -1
- package/build-module/index.js +10 -0
- package/build-module/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +6 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +15 -15
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/missing/edit.native.js +17 -65
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +0 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +2 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +27 -5
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/page-list-item/edit.js +3 -1
- package/build-module/page-list-item/edit.js.map +1 -1
- package/build-module/paragraph/index.js +7 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/pattern/index.js +2 -1
- package/build-module/pattern/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/editor-rtl.css +50 -0
- package/build-style/editor.css +50 -0
- package/build-style/form-input/editor-rtl.css +106 -0
- package/build-style/form-input/editor.css +106 -0
- package/build-style/form-input/style-rtl.css +135 -0
- package/build-style/form-input/style.css +135 -0
- package/build-style/form-submission-notification/editor-rtl.css +118 -0
- package/build-style/form-submission-notification/editor.css +118 -0
- package/build-style/form-submit-button/style-rtl.css +91 -0
- package/build-style/form-submit-button/style.css +91 -0
- package/build-style/image/style-rtl.css +39 -5
- package/build-style/image/style.css +39 -5
- package/build-style/query/style-rtl.css +0 -10
- package/build-style/query/style.css +0 -10
- package/build-style/style-rtl.css +87 -5
- package/build-style/style.css +87 -5
- package/package.json +32 -32
- package/src/block/block.json +2 -1
- package/src/code/edit.native.js +15 -1
- package/src/cover/block.json +0 -3
- package/src/cover/deprecated.js +151 -1
- package/src/cover/edit/index.js +12 -3
- package/src/cover/edit/inspector-controls.js +19 -25
- package/src/cover/save.js +2 -1
- package/src/cover/shared.js +1 -1
- package/src/editor.scss +2 -0
- package/src/footnotes/block.json +1 -0
- package/src/form/block.json +60 -0
- package/src/form/edit.js +179 -0
- package/src/form/index.js +20 -0
- package/src/form/index.php +214 -0
- package/src/form/init.js +6 -0
- package/src/form/save.js +20 -0
- package/src/form/utils.js +39 -0
- package/src/form/variations.js +139 -0
- package/src/form/view.js +41 -0
- package/src/form-input/block.json +73 -0
- package/src/form-input/edit.js +151 -0
- package/src/form-input/editor.scss +24 -0
- package/src/form-input/index.js +20 -0
- package/src/form-input/index.php +45 -0
- package/src/form-input/init.js +6 -0
- package/src/form-input/save.js +83 -0
- package/src/form-input/style.scss +61 -0
- package/src/form-input/variations.js +82 -0
- package/src/form-submission-notification/block.json +19 -0
- package/src/form-submission-notification/edit.js +63 -0
- package/src/form-submission-notification/editor.scss +45 -0
- package/src/form-submission-notification/index.js +26 -0
- package/src/form-submission-notification/index.php +48 -0
- package/src/form-submission-notification/init.js +6 -0
- package/src/form-submission-notification/save.js +28 -0
- package/src/form-submission-notification/variations.js +59 -0
- package/src/form-submit-button/block.json +14 -0
- package/src/form-submit-button/edit.js +33 -0
- package/src/form-submit-button/index.js +18 -0
- package/src/form-submit-button/init.js +6 -0
- package/src/form-submit-button/save.js +14 -0
- package/src/form-submit-button/style.scss +3 -0
- package/src/group/block.json +0 -1
- package/src/heading/index.js +4 -2
- package/src/image/image.js +10 -0
- package/src/image/index.php +128 -82
- package/src/image/style.scss +49 -5
- package/src/image/view.js +100 -52
- package/src/index.js +10 -0
- package/src/latest-posts/edit.js +11 -2
- package/src/latest-posts/index.php +17 -8
- package/src/list-item/hooks/use-merge.js +20 -23
- package/src/lock-unlock.js +1 -1
- package/src/missing/edit.native.js +17 -115
- package/src/missing/style.native.scss +0 -67
- package/src/missing/test/edit-integration.native.js +135 -49
- package/src/missing/test/edit.native.js +0 -41
- package/src/navigation/block.json +2 -1
- package/src/navigation/edit/index.js +0 -1
- package/src/navigation/index.php +28 -8
- package/src/navigation/view.js +25 -6
- package/src/page-list-item/edit.js +2 -0
- package/src/paragraph/index.js +10 -0
- package/src/pattern/block.json +2 -1
- package/src/pattern/index.php +0 -3
- package/src/post-navigation-link/index.php +2 -1
- package/src/preformatted/test/edit.native.js +38 -0
- package/src/query/index.php +3 -2
- package/src/query/style.scss +0 -11
- package/src/search/index.php +0 -4
- package/src/style.scss +1 -0
- package/src/template-part/block.json +2 -1
- package/src/template-part/index.php +4 -7
- package/src/verse/test/edit.native.js +37 -0
package/build/image/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blob","require","_components","_compose","_data","_blockEditor","_element","_i18n","_url","_blocks","_icons","_notices","_coreData","_lockUnlock","_util","_useClientWidth","_interopRequireDefault","_edit","_constants","_utils","DimensionsTool","ResolutionTool","unlock","blockEditorPrivateApis","scaleOptions","value","label","_x","help","__","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","caption","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","lightbox","numericWidth","parseInt","undefined","numericHeight","imageRef","useRef","prevCaption","usePrevious","showCaption","setShowCaption","useState","allowResize","getBlock","useSelect","blockEditorStore","image","multiImageSelection","select","getMedia","coreStore","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","useDispatch","createErrorNotice","createSuccessNotice","noticesStore","isLargeViewport","useViewportMatch","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","useClientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","useEffect","isExternalImage","window","fetch","then","response","blob","catch","captionRef","useCallback","node","focus","naturalWidth","naturalHeight","useMemo","current","complete","onResizeStart","onResizeStop","onImageError","embedBlock","createUpgradedEmbedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","isBlobURL","type","allowedTypes","ALLOWED_MEDIA_TYPES","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","switchToBlockType","dimensionsUnitsOptions","useCustomUnits","availableUnits","lightboxSetting","useSetting","showLightboxToggle","allowEditing","lightboxChecked","enabled","dimensionsControl","_react","createElement","onChange","newWidth","newHeight","newScale","newAspectRatio","defaultScale","defaultAspectRatio","unitsOptions","resetAll","sizeControls","InspectorControls","__experimentalToolsPanel","controls","Fragment","BlockControls","group","BlockAlignmentControl","ToolbarButton","onClick","icon","captionIcon","isPressed","__experimentalImageURLInputUI","onChangeUrl","mediaUrl","mediaLink","link","crop","overlayText","MediaReplaceFlow","mediaId","mediaURL","accept","onSelect","ToolbarGroup","upload","__experimentalToolsPanelItem","isShownByDefault","hasValue","onDeselect","TextareaControl","ExternalLink","__nextHasNoMarginBottom","options","ToggleControl","checked","newValue","TextControl","filename","getFilename","defaultedAlt","sprintf","borderProps","useBorderProps","isRounded","className","src","onLoad","event","target","ref","style","objectFit","Spinner","fallbackClientWidth","__experimentalImageEditor","onSaveImage","imageAttributes","onFinishEditing","numericRatio","evalAspectRatio","customRatio","naturalRatio","ratio","currentWidth","currentHeight","minWidth","MIN_SIZE","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","isRTL","ResizableBox","display","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","offsetWidth","String","resizeRatio","RichText","isEmpty","identifier","__experimentalGetElementClassName","tagName","placeholder","inlineToolbar","__unstableOnSplitAtEnd","createBlock","getDefaultBlockName"],"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":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAaA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAcA,IAAAK,QAAA,GAAAL,OAAA;AAOA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAMA,IAAAU,QAAA,G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QACA;QACA;QACAhH,aAAa,CAAE;UACdqB,KAAK,EAAG,GAAGmO,GAAG,CAACC,WAAa,IAAG;UAC/BnO,MAAM,EAAE,MAAM;UACdC,WAAW,EACV2M,KAAK,KAAKD,YAAY,GACnBnM,SAAS,GACT4N,MAAM,CAAExB,KAAM;QACnB,CAAE,CAAC;MACJ,CAAG;MACHyB,WAAW,EAAG7O,KAAK,KAAK,QAAQ,GAAG,CAAC,GAAG;IAAG,GAExCiH,GACW,CACd;EACF;EAEA,IAAK,CAAEpH,GAAG,IAAI,CAAEb,YAAY,EAAG;IAC9B,OAAOoK,YAAY;EACpB;EAEA,OACC,IAAAX,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAe,QAAA,QAGG,CAAExK,YAAY,IAAIuK,QAAQ,EAC1BtC,GAAG,EACH3F,WAAW,KACV,CAAEwN,qBAAQ,CAACC,OAAO,CAAEhP,OAAQ,CAAC,IAAIZ,UAAU,CAAE,IAC9C,IAAAsJ,MAAA,CAAAC,aAAA,EAACpL,YAAA,CAAAwR,QAAQ;IACRE,UAAU,EAAC,SAAS;IACpB9C,SAAS,EAAG,IAAA+C,8CAAiC,EAC5C,SACD,CAAG;IACH1C,GAAG,EAAG/G,UAAY;IAClB0J,OAAO,EAAC,YAAY;IACpB,cAAa,IAAApQ,QAAE,EAAE,oBAAqB,CAAG;IACzCqQ,WAAW,EAAG,IAAArQ,QAAE,EAAE,aAAc,CAAG;IACnCJ,KAAK,EAAGqB,OAAS;IACjB4I,QAAQ,EAAKjK,KAAK,IACjBQ,aAAa,CAAE;MAAEa,OAAO,EAAErB;IAAM,CAAE,CAClC;IACD0Q,aAAa;IACbC,sBAAsB,EAAGA,CAAA,KACxBjQ,iBAAiB,CAChB,IAAAkQ,mBAAW,EAAE,IAAAC,2BAAmB,EAAC,CAAE,CACpC;EACA,CACD,CAEF,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["_blob","require","_components","_compose","_data","_blockEditor","_element","_i18n","_url","_blocks","_icons","_notices","_coreData","_lockUnlock","_util","_useClientWidth","_interopRequireDefault","_edit","_constants","_utils","DimensionsTool","ResolutionTool","unlock","blockEditorPrivateApis","scaleOptions","value","label","_x","help","__","Image","temporaryURL","attributes","setAttributes","isSelected","insertBlocksAfter","onReplace","onSelectImage","onSelectURL","onUploadError","containerRef","context","clientId","blockEditingMode","url","alt","caption","align","id","href","rel","linkClass","linkDestination","title","width","height","aspectRatio","scale","linkTarget","sizeSlug","lightbox","numericWidth","parseInt","undefined","numericHeight","imageRef","useRef","prevCaption","usePrevious","showCaption","setShowCaption","useState","allowResize","getBlock","useSelect","blockEditorStore","image","multiImageSelection","select","getMedia","coreStore","getMultiSelectedBlockClientIds","getBlockName","multiSelectedClientIds","length","every","_clientId","canInsertCover","imageEditing","imageSizes","maxWidth","mediaUpload","getBlockRootClientId","getSettings","canInsertBlockType","rootClientId","settings","replaceBlocks","toggleSelection","useDispatch","createErrorNotice","createSuccessNotice","noticesStore","isLargeViewport","useViewportMatch","isWideAligned","includes","loadedNaturalWidth","loadedNaturalHeight","setLoadedNaturalSize","isEditingImage","setIsEditingImage","externalBlob","setExternalBlob","clientWidth","useClientWidth","hasNonContentControls","isResizable","imageSizeOptions","filter","slug","media_details","sizes","source_url","map","name","canUploadMedia","useEffect","isExternalImage","window","fetch","then","response","blob","catch","captionRef","useCallback","node","focus","naturalWidth","naturalHeight","useMemo","current","complete","onResizeStart","onResizeStop","onImageError","embedBlock","createUpgradedEmbedBlock","onSetHref","props","onSetTitle","updateAlt","newAlt","updateImage","newSizeSlug","newUrl","uploadExternal","filesList","onFileChange","img","isBlobURL","type","allowedTypes","ALLOWED_MEDIA_TYPES","onError","message","updateAlignment","nextAlign","extraUpdatedAttributes","canEditImage","allowCrop","switchToCover","switchToBlockType","dimensionsUnitsOptions","useCustomUnits","availableUnits","lightboxSetting","useSetting","showLightboxToggle","allowEditing","lightboxChecked","enabled","lightboxToggleDisabled","dimensionsControl","_react","createElement","onChange","newWidth","newHeight","newScale","newAspectRatio","defaultScale","defaultAspectRatio","unitsOptions","resetAll","sizeControls","InspectorControls","__experimentalToolsPanel","controls","Fragment","BlockControls","group","BlockAlignmentControl","ToolbarButton","onClick","icon","captionIcon","isPressed","__experimentalImageURLInputUI","onChangeUrl","mediaUrl","mediaLink","link","crop","overlayText","MediaReplaceFlow","mediaId","mediaURL","accept","onSelect","ToolbarGroup","upload","__experimentalToolsPanelItem","isShownByDefault","hasValue","onDeselect","TextareaControl","ExternalLink","__nextHasNoMarginBottom","options","ToggleControl","checked","newValue","disabled","TextControl","filename","getFilename","defaultedAlt","sprintf","borderProps","useBorderProps","isRounded","className","src","onLoad","event","target","ref","style","objectFit","Spinner","fallbackClientWidth","__experimentalImageEditor","onSaveImage","imageAttributes","onFinishEditing","numericRatio","evalAspectRatio","customRatio","naturalRatio","ratio","currentWidth","currentHeight","minWidth","MIN_SIZE","minHeight","maxWidthBuffer","showRightHandle","showLeftHandle","isRTL","ResizableBox","display","size","showHandle","maxHeight","lockAspectRatio","enable","top","right","bottom","left","direction","elt","offsetWidth","String","resizeRatio","RichText","isEmpty","identifier","__experimentalGetElementClassName","tagName","placeholder","inlineToolbar","__unstableOnSplitAtEnd","createBlock","getDefaultBlockName"],"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 lightboxToggleDisabled = linkDestination !== 'none';\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\tdisabled={ lightboxToggleDisabled }\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlightboxToggleDisabled\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'“Expand on click” scales the image up, and can’t be combined with a link.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\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":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAaA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAcA,IAAAK,QAAA,GAAAL,OAAA;AAOA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAMA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,SAAA,GAAAX,OAAA;AAKA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AACA,IAAAc,eAAA,GAAAC,sBAAA,CAAAf,OAAA;AACA,IAAAgB,KAAA,GAAAhB,OAAA;AAKA,IAAAiB,UAAA,GAAAjB,OAAA;AACA,IAAAkB,MAAA,GAAAlB,OAAA;AApEA;AACA;AACA;;AAsDA;AACA;AACA;;AAMA;AACA;AACA;;AAIA,MAAM;EAAEmB,cAAc;EAAEC;AAAe,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAE3E,MAAMC,YAAY,GAAG,CACpB;EACCC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAO,EAAE,qCAAsC,CAAC;EAC3DC,IAAI,EAAE,I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EAEA,OACC,IAAAX,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAe,QAAA,QAGG,CAAEzK,YAAY,IAAIwK,QAAQ,EAC1BvC,GAAG,EACH3F,WAAW,KACV,CAAE0N,qBAAQ,CAACC,OAAO,CAAElP,OAAQ,CAAC,IAAIZ,UAAU,CAAE,IAC9C,IAAAuJ,MAAA,CAAAC,aAAA,EAACrL,YAAA,CAAA0R,QAAQ;IACRE,UAAU,EAAC,SAAS;IACpB9C,SAAS,EAAG,IAAA+C,8CAAiC,EAC5C,SACD,CAAG;IACH1C,GAAG,EAAGjH,UAAY;IAClB4J,OAAO,EAAC,YAAY;IACpB,cAAa,IAAAtQ,QAAE,EAAE,oBAAqB,CAAG;IACzCuQ,WAAW,EAAG,IAAAvQ,QAAE,EAAE,aAAc,CAAG;IACnCJ,KAAK,EAAGqB,OAAS;IACjB6I,QAAQ,EAAKlK,KAAK,IACjBQ,aAAa,CAAE;MAAEa,OAAO,EAAErB;IAAM,CAAE,CAClC;IACD4Q,aAAa;IACbC,sBAAsB,EAAGA,CAAA,KACxBnQ,iBAAiB,CAChB,IAAAoQ,mBAAW,EAAE,IAAAC,2BAAmB,EAAC,CAAE,CACpC;EACA,CACD,CAEF,CAAC;AAEL"}
|
package/build/image/view.js
CHANGED
|
@@ -90,8 +90,9 @@ function handleScroll(context) {
|
|
|
90
90
|
context.core.image.initialized = true;
|
|
91
91
|
context.core.image.lastFocusedElement = window.document.activeElement;
|
|
92
92
|
context.core.image.scrollDelta = 0;
|
|
93
|
+
context.core.image.pointerType = event.pointerType;
|
|
93
94
|
context.core.image.lightboxEnabled = true;
|
|
94
|
-
setStyles(context,
|
|
95
|
+
setStyles(context, context.core.image.imageRef);
|
|
95
96
|
context.core.image.scrollTopReset = window.pageYOffset || document.documentElement.scrollTop;
|
|
96
97
|
|
|
97
98
|
// In most cases, this value will be 0, but this is included
|
|
@@ -112,7 +113,8 @@ function handleScroll(context) {
|
|
|
112
113
|
window.addEventListener('scroll', scrollCallback, false);
|
|
113
114
|
},
|
|
114
115
|
hideLightbox: async ({
|
|
115
|
-
context
|
|
116
|
+
context,
|
|
117
|
+
event
|
|
116
118
|
}) => {
|
|
117
119
|
context.core.image.hideAnimationEnabled = true;
|
|
118
120
|
if (context.core.image.lightboxEnabled) {
|
|
@@ -126,9 +128,16 @@ function handleScroll(context) {
|
|
|
126
128
|
window.removeEventListener('scroll', scrollCallback);
|
|
127
129
|
}, 450);
|
|
128
130
|
context.core.image.lightboxEnabled = false;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
|
|
132
|
+
// We want to avoid drawing attention to the button
|
|
133
|
+
// after the lightbox closes for mouse and touch users.
|
|
134
|
+
// Note that the `event.pointerType` property returns
|
|
135
|
+
// as an empty string if a keyboard fired the event.
|
|
136
|
+
if (event.pointerType === '') {
|
|
137
|
+
context.core.image.lastFocusedElement.focus({
|
|
138
|
+
preventScroll: true
|
|
139
|
+
});
|
|
140
|
+
}
|
|
132
141
|
}
|
|
133
142
|
},
|
|
134
143
|
handleKeydown: ({
|
|
@@ -155,8 +164,9 @@ function handleScroll(context) {
|
|
|
155
164
|
}
|
|
156
165
|
}
|
|
157
166
|
},
|
|
167
|
+
// This is fired just by lazily loaded
|
|
168
|
+
// images on the page, not all images.
|
|
158
169
|
handleLoad: ({
|
|
159
|
-
state,
|
|
160
170
|
context,
|
|
161
171
|
effects,
|
|
162
172
|
ref
|
|
@@ -164,7 +174,6 @@ function handleScroll(context) {
|
|
|
164
174
|
context.core.image.imageLoaded = true;
|
|
165
175
|
context.core.image.imageCurrentSrc = ref.currentSrc;
|
|
166
176
|
effects.core.image.setButtonStyles({
|
|
167
|
-
state,
|
|
168
177
|
context,
|
|
169
178
|
ref
|
|
170
179
|
});
|
|
@@ -202,7 +211,17 @@ function handleScroll(context) {
|
|
|
202
211
|
roleAttribute: ({
|
|
203
212
|
context
|
|
204
213
|
}) => {
|
|
205
|
-
return context.core.image.lightboxEnabled ? 'dialog' :
|
|
214
|
+
return context.core.image.lightboxEnabled ? 'dialog' : null;
|
|
215
|
+
},
|
|
216
|
+
ariaModal: ({
|
|
217
|
+
context
|
|
218
|
+
}) => {
|
|
219
|
+
return context.core.image.lightboxEnabled ? 'true' : null;
|
|
220
|
+
},
|
|
221
|
+
dialogLabel: ({
|
|
222
|
+
context
|
|
223
|
+
}) => {
|
|
224
|
+
return context.core.image.lightboxEnabled ? context.core.image.dialogLabel : null;
|
|
206
225
|
},
|
|
207
226
|
lightboxObjectFit: ({
|
|
208
227
|
context
|
|
@@ -214,7 +233,7 @@ function handleScroll(context) {
|
|
|
214
233
|
enlargedImgSrc: ({
|
|
215
234
|
context
|
|
216
235
|
}) => {
|
|
217
|
-
return context.core.image.initialized ? context.core.image.imageUploadedSrc : '';
|
|
236
|
+
return context.core.image.initialized ? context.core.image.imageUploadedSrc : 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
|
|
218
237
|
}
|
|
219
238
|
}
|
|
220
239
|
}
|
|
@@ -222,10 +241,11 @@ function handleScroll(context) {
|
|
|
222
241
|
effects: {
|
|
223
242
|
core: {
|
|
224
243
|
image: {
|
|
225
|
-
|
|
244
|
+
initOriginImage: ({
|
|
226
245
|
context,
|
|
227
246
|
ref
|
|
228
247
|
}) => {
|
|
248
|
+
context.core.image.imageRef = ref;
|
|
229
249
|
if (ref.complete) {
|
|
230
250
|
context.core.image.imageLoaded = true;
|
|
231
251
|
context.core.image.imageCurrentSrc = ref.currentSrc;
|
|
@@ -235,17 +255,22 @@ function handleScroll(context) {
|
|
|
235
255
|
context,
|
|
236
256
|
ref
|
|
237
257
|
}) => {
|
|
238
|
-
context.core.image.figureRef = ref.querySelector('figure');
|
|
239
|
-
context.core.image.imageRef = ref.querySelector('img');
|
|
240
258
|
if (context.core.image.lightboxEnabled) {
|
|
241
259
|
const focusableElements = ref.querySelectorAll(focusableSelectors);
|
|
242
260
|
context.core.image.firstFocusableElement = focusableElements[0];
|
|
243
261
|
context.core.image.lastFocusableElement = focusableElements[focusableElements.length - 1];
|
|
244
|
-
|
|
262
|
+
|
|
263
|
+
// We want to avoid drawing unnecessary attention to the close
|
|
264
|
+
// button for mouse and touch users. Note that even if opening
|
|
265
|
+
// the lightbox via keyboard, the event fired is of type
|
|
266
|
+
// `pointerEvent`, so we need to rely on the `event.pointerType`
|
|
267
|
+
// property, which returns an empty string for keyboard events.
|
|
268
|
+
if (context.core.image.pointerType === '') {
|
|
269
|
+
ref.querySelector('.close-button').focus();
|
|
270
|
+
}
|
|
245
271
|
}
|
|
246
272
|
},
|
|
247
273
|
setButtonStyles: ({
|
|
248
|
-
state,
|
|
249
274
|
context,
|
|
250
275
|
ref
|
|
251
276
|
}) => {
|
|
@@ -257,43 +282,60 @@ function handleScroll(context) {
|
|
|
257
282
|
} = ref;
|
|
258
283
|
|
|
259
284
|
// If the image isn't loaded yet, we can't
|
|
260
|
-
// calculate
|
|
285
|
+
// calculate where the button should be.
|
|
261
286
|
if (naturalWidth === 0 || naturalHeight === 0) {
|
|
262
287
|
return;
|
|
263
288
|
}
|
|
289
|
+
const figure = ref.parentElement;
|
|
290
|
+
const figureWidth = ref.parentElement.clientWidth;
|
|
264
291
|
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
292
|
+
// We need special handling for the height because
|
|
293
|
+
// a caption will cause the figure to be taller than
|
|
294
|
+
// the image, which means we need to account for that
|
|
295
|
+
// when calculating the placement of the button in the
|
|
296
|
+
// top right corner of the image.
|
|
297
|
+
let figureHeight = ref.parentElement.clientHeight;
|
|
298
|
+
const caption = figure.querySelector('figcaption');
|
|
299
|
+
if (caption) {
|
|
300
|
+
const captionComputedStyle = window.getComputedStyle(caption);
|
|
301
|
+
figureHeight = figureHeight - caption.offsetHeight - parseFloat(captionComputedStyle.marginTop) - parseFloat(captionComputedStyle.marginBottom);
|
|
302
|
+
}
|
|
303
|
+
const buttonOffsetTop = figureHeight - offsetHeight;
|
|
304
|
+
const buttonOffsetRight = figureWidth - offsetWidth;
|
|
271
305
|
|
|
306
|
+
// In the case of an image with object-fit: contain, the
|
|
307
|
+
// size of the <img> element can be larger than the image itself,
|
|
308
|
+
// so we need to calculate where to place the button.
|
|
309
|
+
if (context.core.image.scaleAttr === 'contain') {
|
|
272
310
|
// Natural ratio of the image.
|
|
273
311
|
const naturalRatio = naturalWidth / naturalHeight;
|
|
274
312
|
// Offset ratio of the image.
|
|
275
313
|
const offsetRatio = offsetWidth / offsetHeight;
|
|
276
|
-
if (naturalRatio
|
|
314
|
+
if (naturalRatio >= offsetRatio) {
|
|
277
315
|
// If it reaches the width first, keep
|
|
278
|
-
// the width and
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
context.core.image.
|
|
282
|
-
context.core.image.imageButtonTop = (offsetHeight - buttonHeight) / 2;
|
|
316
|
+
// the width and compute the height.
|
|
317
|
+
const referenceHeight = offsetWidth / naturalRatio;
|
|
318
|
+
context.core.image.imageButtonTop = (offsetHeight - referenceHeight) / 2 + buttonOffsetTop + 10;
|
|
319
|
+
context.core.image.imageButtonRight = buttonOffsetRight + 10;
|
|
283
320
|
} else {
|
|
284
321
|
// If it reaches the height first, keep
|
|
285
|
-
// the height and
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
context.core.image.
|
|
289
|
-
context.core.image.imageButtonLeft = (offsetWidth - buttonWidth) / 2;
|
|
322
|
+
// the height and compute the width.
|
|
323
|
+
const referenceWidth = offsetHeight * naturalRatio;
|
|
324
|
+
context.core.image.imageButtonTop = buttonOffsetTop + 10;
|
|
325
|
+
context.core.image.imageButtonRight = (offsetWidth - referenceWidth) / 2 + buttonOffsetRight + 10;
|
|
290
326
|
}
|
|
291
327
|
} else {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
328
|
+
context.core.image.imageButtonTop = buttonOffsetTop + 10;
|
|
329
|
+
context.core.image.imageButtonRight = buttonOffsetRight + 10;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
setStylesOnResize: ({
|
|
333
|
+
state,
|
|
334
|
+
context,
|
|
335
|
+
ref
|
|
336
|
+
}) => {
|
|
337
|
+
if (context.core.image.lightboxEnabled && (state.core.image.windowWidth || state.core.image.windowHeight)) {
|
|
338
|
+
setStyles(context, ref);
|
|
297
339
|
}
|
|
298
340
|
}
|
|
299
341
|
}
|
|
@@ -317,7 +359,7 @@ function handleScroll(context) {
|
|
|
317
359
|
* @param {Object} context - An Interactivity API context
|
|
318
360
|
* @param {Object} event - A triggering event
|
|
319
361
|
*/
|
|
320
|
-
function setStyles(context,
|
|
362
|
+
function setStyles(context, ref) {
|
|
321
363
|
// The reference img element lies adjacent
|
|
322
364
|
// to the event target button in the DOM.
|
|
323
365
|
let {
|
|
@@ -325,11 +367,11 @@ function setStyles(context, event) {
|
|
|
325
367
|
naturalHeight,
|
|
326
368
|
offsetWidth: originalWidth,
|
|
327
369
|
offsetHeight: originalHeight
|
|
328
|
-
} =
|
|
370
|
+
} = ref;
|
|
329
371
|
let {
|
|
330
372
|
x: screenPosX,
|
|
331
373
|
y: screenPosY
|
|
332
|
-
} =
|
|
374
|
+
} = ref.getBoundingClientRect();
|
|
333
375
|
|
|
334
376
|
// Natural ratio of the image clicked to open the lightbox.
|
|
335
377
|
const naturalRatio = naturalWidth / naturalHeight;
|