@wordpress/block-library 9.19.2 → 9.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 +4 -0
- package/build/archives/edit.js +2 -2
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +66 -33
- package/build/audio/edit.js.map +1 -1
- package/build/avatar/index.js +8 -3
- package/build/avatar/index.js.map +1 -1
- package/build/button/edit.js +43 -16
- package/build/button/edit.js.map +1 -1
- package/build/categories/edit.js +3 -3
- package/build/categories/edit.js.map +1 -1
- package/build/comment-template/hooks.js +6 -0
- package/build/comment-template/hooks.js.map +1 -1
- package/build/cover/index.js +8 -1
- package/build/cover/index.js.map +1 -1
- package/build/embed/edit.js +4 -1
- package/build/embed/edit.js.map +1 -1
- package/build/image/constants.js +2 -1
- package/build/image/constants.js.map +1 -1
- package/build/image/edit.js +3 -2
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +98 -80
- package/build/image/image.js.map +1 -1
- package/build/navigation/edit/index.js +8 -4
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation-link/edit.js +27 -8
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-author/index.js +8 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/rss/edit.js +21 -1
- package/build/rss/edit.js.map +1 -1
- package/build/rss/index.js +7 -0
- package/build/rss/index.js.map +1 -1
- package/build/site-logo/index.js +8 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-title/edit.js +1 -1
- package/build/site-title/edit.js.map +1 -1
- package/build/social-links/index.js +1 -0
- package/build/social-links/index.js.map +1 -1
- package/build/table-of-contents/edit.js +50 -8
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +13 -4
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/table-of-contents/index.js +3 -0
- package/build/table-of-contents/index.js.map +1 -1
- package/build-module/archives/edit.js +2 -2
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +68 -35
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/avatar/index.js +8 -3
- package/build-module/avatar/index.js.map +1 -1
- package/build-module/button/edit.js +44 -17
- package/build-module/button/edit.js.map +1 -1
- package/build-module/categories/edit.js +3 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +6 -0
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/cover/index.js +8 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/edit.js +4 -1
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/image/constants.js +1 -0
- package/build-module/image/constants.js.map +1 -1
- package/build-module/image/edit.js +3 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +102 -84
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation/edit/index.js +8 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +28 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-author/index.js +8 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/rss/edit.js +22 -2
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/rss/index.js +7 -0
- package/build-module/rss/index.js.map +1 -1
- package/build-module/site-logo/index.js +8 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-title/edit.js +1 -1
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/social-links/index.js +1 -0
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table-of-contents/edit.js +52 -10
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +13 -4
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/table-of-contents/index.js +3 -0
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-style/editor-rtl.css +0 -9
- package/build-style/editor.css +0 -9
- package/build-style/image/editor-rtl.css +0 -9
- package/build-style/image/editor.css +0 -9
- package/package.json +35 -35
- package/src/archives/edit.js +2 -2
- package/src/audio/edit.js +84 -33
- package/src/avatar/block.json +8 -3
- package/src/button/edit.js +69 -24
- package/src/categories/edit.js +3 -3
- package/src/comment-template/hooks.js +14 -6
- package/src/cover/block.json +8 -1
- package/src/embed/edit.js +7 -1
- package/src/image/constants.js +1 -0
- package/src/image/edit.js +3 -3
- package/src/image/editor.scss +0 -13
- package/src/image/image.js +124 -134
- package/src/navigation/edit/index.js +4 -0
- package/src/navigation-link/edit.js +45 -11
- package/src/post-author/block.json +8 -1
- package/src/post-featured-image/edit.js +2 -1
- package/src/rss/block.json +7 -0
- package/src/rss/edit.js +21 -0
- package/src/rss/index.php +27 -9
- package/src/site-logo/block.json +8 -1
- package/src/site-title/edit.js +1 -1
- package/src/site-title/index.php +1 -1
- package/src/social-links/block.json +1 -0
- package/src/table-of-contents/block.json +3 -0
- package/src/table-of-contents/edit.js +45 -4
- package/src/table-of-contents/hooks.js +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","isBlobURL","createBlobURL","createBlock","getBlockBindingsSource","Placeholder","useDispatch","useSelect","BlockIcon","useBlockProps","MediaPlaceholder","store","blockEditorStore","__experimentalUseBorderProps","useBorderProps","__experimentalGetShadowClassesAndStyles","getShadowClassesAndStyles","useBlockEditingMode","useEffect","useRef","useState","__","sprintf","image","icon","plugins","pluginsIcon","noticesStore","useResizeObserver","useUploadMediaFromBlobURL","Image","isValidFileType","useMaxWidthObserver","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isExternalImage","id","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","isSingleSelected","className","insertBlocksAfter","onReplace","context","clientId","__unstableParentLayout","parentLayout","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","metadata","temporaryURL","setTemporaryURL","blob","containerRef","isMaxWidthContainerWidth","type","maxWidthObserver","maxContentWidth","placeholderResizeListener","placeholderWidth","isSmallContainer","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","replaceBlock","undefined","getSettings","getBlockRootClientId","getBlockName","canInsertBlockType","blockEditingMode","createErrorNotice","onUploadError","message","src","onSelectImagesList","images","win","ownerDocument","defaultView","every","file","File","files","rootClientId","some","imageBlocks","map","galleryBlock","onSelectImage","media","Array","isArray","title","imageDefaultSize","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","settings","defaultProps","link","href","onSelectURL","newURL","allowedTypes","onChange","onError","isExternal","mediaPreview","borderProps","shadowProps","classes","style","keys","length","blockProps","ref","lockUrlControls","lockUrlControlsMessage","select","blockBindingsSource","bindings","source","canUserEditValue","args","label","placeholder","content","withIllustration","instructions","objectFit","children","parentLayoutType","onSelect","accept","handleUpload","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL, createBlobURL } from '@wordpress/blob';\nimport { createBlock, getBlockBindingsSource } from '@wordpress/blocks';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tuseBlockProps,\n\tMediaPlaceholder,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { image as icon, plugins as pluginsIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\nimport Image from './image';\nimport { isValidFileType } from './utils';\nimport { useMaxWidthObserver } from './use-max-width-observer';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t\tmetadata,\n\t} = attributes;\n\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\n\tconst containerRef = useRef();\n\t// Only observe the max width from the parent container when the parent layout is not flex nor grid.\n\t// This won't work for them because the container width changes with the image.\n\t// TODO: Find a way to observe the container width for flex and grid layouts.\n\tconst isMaxWidthContainerWidth =\n\t\t! parentLayout ||\n\t\t( parentLayout.type !== 'flex' && parentLayout.type !== 'grid' );\n\tconst [ maxWidthObserver, maxContentWidth ] = useMaxWidthObserver();\n\n\tconst [ placeholderResizeListener, { width: placeholderWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst isSmallContainer = placeholderWidth && placeholderWidth < 160;\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ __unstableMarkNextChangeAsNotPersistent, align, setAttributes ] );\n\n\tconst {\n\t\tgetSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tblob: undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectImagesList( images ) {\n\t\tconst win = containerRef.current?.ownerDocument.defaultView;\n\n\t\tif ( images.every( ( file ) => file instanceof win.File ) ) {\n\t\t\t/** @type {File[]} */\n\t\t\tconst files = images;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\tif ( files.some( ( file ) => ! isValidFileType( file ) ) ) {\n\t\t\t\t// Copied from the same notice in the gallery block.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'If uploading to a gallery all files need to be image formats'\n\t\t\t\t\t),\n\t\t\t\t\t{ id: 'gallery-upload-invalid-file', type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst imageBlocks = files\n\t\t\t\t.filter( ( file ) => isValidFileType( file ) )\n\t\t\t\t.map( ( file ) =>\n\t\t\t\t\tcreateBlock( 'core/image', {\n\t\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\tif ( getBlockName( rootClientId ) === 'core/gallery' ) {\n\t\t\t\treplaceBlock( clientId, imageBlocks );\n\t\t\t} else if ( canInsertBlockType( 'core/gallery', rootClientId ) ) {\n\t\t\t\tconst galleryBlock = createBlock(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\t{},\n\t\t\t\t\timageBlocks\n\t\t\t\t);\n\n\t\t\t\treplaceBlock( clientId, galleryBlock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( Array.isArray( media ) ) {\n\t\t\tonSelectImagesList( media );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: getSettings().imageDefaultSize,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectImage,\n\t\tonError: onUploadError,\n\t} );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName=\"edit-image-preview\"\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: containerRef,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst { lockUrlControls = false, lockUrlControlsMessage } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\tmetadata?.bindings?.url?.source\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! metadata?.bindings?.url &&\n\t\t\t\t\t! blockBindingsSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: metadata?.bindings?.url?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockUrlControlsMessage: blockBindingsSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\tblockBindingsSource.label\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t};\n\t\t},\n\t\t[ context, isSingleSelected, metadata?.bindings?.url ]\n\t);\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ clsx( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSingleSelected,\n\t\t\t\t} ) }\n\t\t\t\ticon={\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t( lockUrlControls ? pluginsIcon : icon )\n\t\t\t\t}\n\t\t\t\twithIllustration={ ! isSingleSelected || isSmallContainer }\n\t\t\t\tlabel={ ! isSmallContainer && __( 'Image' ) }\n\t\t\t\tinstructions={\n\t\t\t\t\t! lockUrlControls &&\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Drag and drop an image, upload, or choose from your library.'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tstyle={ {\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\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t...shadowProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ lockUrlControls &&\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\tlockUrlControlsMessage }\n\n\t\t\t\t{ ! lockUrlControls && ! isSmallContainer && content }\n\t\t\t\t{ placeholderResizeListener }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t<Image\n\t\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSingleSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\t\tcontext={ context }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t\t\tparentLayoutType={ parentLayout?.type }\n\t\t\t\t\tmaxContentWidth={ maxContentWidth }\n\t\t\t\t/>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\thandleUpload={ ( files ) => files.length === 1 }\n\t\t\t\t\tvalue={ { id, src } }\n\t\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t\t{\n\t\t\t\t// The listener cannot be placed as the first element as it will break the in-between inserter.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120\n\t\t\t\tisSingleSelected && isMaxWidthContainerWidth && maxWidthObserver\n\t\t\t}\n\t\t</>\n\t);\n}\n\nexport default ImageEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,aAAa,QAAQ,iBAAiB;AAC1D,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,mBAAmB;AACvE,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,4BAA4B,IAAIC,cAAc,EAC9CC,uCAAuC,IAAIC,yBAAyB,EACpEC,m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AC,eACFnD,IAAA,CAAC7B,gBAAgB;QAChBc,IAAI,eAAGe,IAAA,CAAC/B,SAAS;UAACgB,IAAI,EAAGA;QAAM,CAAE,CAAG;QACpCqJ,QAAQ,EAAGlD,aAAe;QAC1BmB,WAAW,EAAGA,WAAa;QAC3BI,OAAO,EAAGxC,aAAe;QACzB4D,WAAW,EAAGA,WAAa;QAC3BQ,MAAM,EAAC,SAAS;QAChB9B,YAAY,EAAG3G,mBAAqB;QACpC0I,YAAY,EAAK1D,KAAK,IAAMA,KAAK,CAACqC,MAAM,KAAK,CAAG;QAChDsB,KAAK,EAAG;UAAEtH,EAAE;UAAEkD;QAAI,CAAG;QACrBwC,YAAY,EAAGA,YAAc;QAC7B6B,mBAAmB,EAAG9F,YAAY,IAAI9B;MAAK,CAC3C,CAAC;IAAA,CACK,CAAC;IAER;IACA;IACAa,gBAAgB,IAAIqB,wBAAwB,IAAIE,gBAAgB;EAAA,CAEhE,CAAC;AAEL;AAEA,eAAe3B,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","isBlobURL","createBlobURL","createBlock","getBlockBindingsSource","Placeholder","useDispatch","useSelect","BlockIcon","useBlockProps","MediaPlaceholder","store","blockEditorStore","__experimentalUseBorderProps","useBorderProps","__experimentalGetShadowClassesAndStyles","getShadowClassesAndStyles","useBlockEditingMode","useEffect","useRef","useState","__","sprintf","image","icon","plugins","pluginsIcon","noticesStore","useResizeObserver","useUploadMediaFromBlobURL","Image","isValidFileType","useMaxWidthObserver","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isExternalImage","id","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","isSingleSelected","className","insertBlocksAfter","onReplace","context","clientId","__unstableParentLayout","parentLayout","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","metadata","temporaryURL","setTemporaryURL","blob","containerRef","layoutType","type","default","isMaxWidthContainerWidth","maxWidthObserver","maxContentWidth","placeholderResizeListener","placeholderWidth","isSmallContainer","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","replaceBlock","undefined","getSettings","getBlockRootClientId","getBlockName","canInsertBlockType","blockEditingMode","createErrorNotice","onUploadError","message","src","onSelectImagesList","images","win","ownerDocument","defaultView","every","file","File","files","rootClientId","some","imageBlocks","map","galleryBlock","onSelectImage","media","Array","isArray","title","imageDefaultSize","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","settings","defaultProps","link","href","onSelectURL","newURL","allowedTypes","onChange","onError","isExternal","mediaPreview","borderProps","shadowProps","classes","style","keys","length","blockProps","ref","lockUrlControls","lockUrlControlsMessage","select","blockBindingsSource","bindings","source","canUserEditValue","args","label","placeholder","content","withIllustration","instructions","objectFit","children","parentLayoutType","onSelect","accept","handleUpload","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL, createBlobURL } from '@wordpress/blob';\nimport { createBlock, getBlockBindingsSource } from '@wordpress/blocks';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tuseBlockProps,\n\tMediaPlaceholder,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { image as icon, plugins as pluginsIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\nimport Image from './image';\nimport { isValidFileType } from './utils';\nimport { useMaxWidthObserver } from './use-max-width-observer';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t\tmetadata,\n\t} = attributes;\n\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\n\tconst containerRef = useRef();\n\t// Only observe the max width from the parent container when the parent layout is not flex nor grid.\n\t// This won't work for them because the container width changes with the image.\n\t// TODO: Find a way to observe the container width for flex and grid layouts.\n\tconst layoutType = parentLayout?.type || parentLayout?.default?.type;\n\tconst isMaxWidthContainerWidth =\n\t\t! layoutType || ( layoutType !== 'flex' && layoutType !== 'grid' );\n\tconst [ maxWidthObserver, maxContentWidth ] = useMaxWidthObserver();\n\n\tconst [ placeholderResizeListener, { width: placeholderWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst isSmallContainer = placeholderWidth && placeholderWidth < 160;\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ __unstableMarkNextChangeAsNotPersistent, align, setAttributes ] );\n\n\tconst {\n\t\tgetSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tblob: undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectImagesList( images ) {\n\t\tconst win = containerRef.current?.ownerDocument.defaultView;\n\n\t\tif ( images.every( ( file ) => file instanceof win.File ) ) {\n\t\t\t/** @type {File[]} */\n\t\t\tconst files = images;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\tif ( files.some( ( file ) => ! isValidFileType( file ) ) ) {\n\t\t\t\t// Copied from the same notice in the gallery block.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'If uploading to a gallery all files need to be image formats'\n\t\t\t\t\t),\n\t\t\t\t\t{ id: 'gallery-upload-invalid-file', type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst imageBlocks = files\n\t\t\t\t.filter( ( file ) => isValidFileType( file ) )\n\t\t\t\t.map( ( file ) =>\n\t\t\t\t\tcreateBlock( 'core/image', {\n\t\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\tif ( getBlockName( rootClientId ) === 'core/gallery' ) {\n\t\t\t\treplaceBlock( clientId, imageBlocks );\n\t\t\t} else if ( canInsertBlockType( 'core/gallery', rootClientId ) ) {\n\t\t\t\tconst galleryBlock = createBlock(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\t{},\n\t\t\t\t\timageBlocks\n\t\t\t\t);\n\n\t\t\t\treplaceBlock( clientId, galleryBlock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( Array.isArray( media ) ) {\n\t\t\tonSelectImagesList( media );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: getSettings().imageDefaultSize,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectImage,\n\t\tonError: onUploadError,\n\t} );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName=\"edit-image-preview\"\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: containerRef,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst { lockUrlControls = false, lockUrlControlsMessage } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\tmetadata?.bindings?.url?.source\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! metadata?.bindings?.url &&\n\t\t\t\t\t! blockBindingsSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: metadata?.bindings?.url?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockUrlControlsMessage: blockBindingsSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\tblockBindingsSource.label\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t};\n\t\t},\n\t\t[ context, isSingleSelected, metadata?.bindings?.url ]\n\t);\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ clsx( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSingleSelected,\n\t\t\t\t} ) }\n\t\t\t\ticon={\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t( lockUrlControls ? pluginsIcon : icon )\n\t\t\t\t}\n\t\t\t\twithIllustration={ ! isSingleSelected || isSmallContainer }\n\t\t\t\tlabel={ ! isSmallContainer && __( 'Image' ) }\n\t\t\t\tinstructions={\n\t\t\t\t\t! lockUrlControls &&\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Drag and drop an image, upload, or choose from your library.'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tstyle={ {\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\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t...shadowProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ lockUrlControls &&\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\tlockUrlControlsMessage }\n\n\t\t\t\t{ ! lockUrlControls && ! isSmallContainer && content }\n\t\t\t\t{ placeholderResizeListener }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t<Image\n\t\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSingleSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\t\tcontext={ context }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t\t\tparentLayoutType={ layoutType }\n\t\t\t\t\tmaxContentWidth={ maxContentWidth }\n\t\t\t\t/>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\thandleUpload={ ( files ) => files.length === 1 }\n\t\t\t\t\tvalue={ { id, src } }\n\t\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t\t{\n\t\t\t\t// The listener cannot be placed as the first element as it will break the in-between inserter.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120\n\t\t\t\tisSingleSelected && isMaxWidthContainerWidth && maxWidthObserver\n\t\t\t}\n\t\t</>\n\t);\n}\n\nexport default ImageEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,aAAa,QAAQ,iBAAiB;AAC1D,SAASC,WAAW,EAAEC,sBAAsB,QAAQ,mBAAmB;AACvE,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,4BAA4B,IAAIC,cAAc,EAC9CC,uCAAuC,IAAIC,yBAAyB,EACpEC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,SAAS,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AAiB,CACnC,CAAC,eACFrD,IAAA,CAAC7B,gBAAgB;QAChBc,IAAI,eAAGe,IAAA,CAAC/B,SAAS;UAACgB,IAAI,EAAGA;QAAM,CAAE,CAAG;QACpCuJ,QAAQ,EAAGlD,aAAe;QAC1BmB,WAAW,EAAGA,WAAa;QAC3BI,OAAO,EAAGxC,aAAe;QACzB4D,WAAW,EAAGA,WAAa;QAC3BQ,MAAM,EAAC,SAAS;QAChB9B,YAAY,EAAG7G,mBAAqB;QACpC4I,YAAY,EAAK1D,KAAK,IAAMA,KAAK,CAACqC,MAAM,KAAK,CAAG;QAChDsB,KAAK,EAAG;UAAExH,EAAE;UAAEoD;QAAI,CAAG;QACrBwC,YAAY,EAAGA,YAAc;QAC7B6B,mBAAmB,EAAGhG,YAAY,IAAI9B;MAAK,CAC3C,CAAC;IAAA,CACK,CAAC;IAER;IACA;IACAa,gBAAgB,IAAIwB,wBAAwB,IAAIC,gBAAgB;EAAA,CAEhE,CAAC;AAEL;AAEA,eAAe7B,SAAS","ignoreList":[]}
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { isBlobURL } from '@wordpress/blob';
|
|
5
5
|
import { ExternalLink, ResizableBox, Spinner, TextareaControl, TextControl, ToolbarButton, ToolbarGroup, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalUseCustomUnits as useCustomUnits, Placeholder, MenuItem, ToolbarItem, DropdownMenu, Popover } from '@wordpress/components';
|
|
6
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
6
|
+
import { useMergeRefs, useResizeObserver, useViewportMatch } from '@wordpress/compose';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
8
|
import { BlockControls, InspectorControls, __experimentalImageURLInputUI as ImageURLInputUI, MediaReplaceFlow, store as blockEditorStore, useSettings, __experimentalImageEditor as ImageEditor, __experimentalUseBorderProps as useBorderProps, __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, privateApis as blockEditorPrivateApis, BlockSettingsMenuControls } from '@wordpress/block-editor';
|
|
9
|
-
import { useEffect, useMemo, useState
|
|
9
|
+
import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
|
|
10
10
|
import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
|
|
11
11
|
import { getFilename } from '@wordpress/url';
|
|
12
12
|
import { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';
|
|
13
13
|
import { crop, overlayText, upload, chevronDown } from '@wordpress/icons';
|
|
14
14
|
import { store as noticesStore } from '@wordpress/notices';
|
|
15
|
-
import { store as coreStore
|
|
15
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
@@ -26,7 +26,7 @@ import { Caption } from '../utils/caption';
|
|
|
26
26
|
* Module constants
|
|
27
27
|
*/
|
|
28
28
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
29
|
-
import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
|
|
29
|
+
import { MIN_SIZE, ALLOWED_MEDIA_TYPES, SIZED_LAYOUTS } from './constants';
|
|
30
30
|
import { evalAspectRatio } from './utils';
|
|
31
31
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
32
|
const {
|
|
@@ -210,18 +210,29 @@ export default function Image({
|
|
|
210
210
|
lightbox,
|
|
211
211
|
metadata
|
|
212
212
|
} = attributes;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
const
|
|
213
|
+
const [imageElement, setImageElement] = useState();
|
|
214
|
+
const [resizeDelta, setResizeDelta] = useState(null);
|
|
215
|
+
const [pixelSize, setPixelSize] = useState({});
|
|
216
|
+
const [offsetTop, setOffsetTop] = useState(0);
|
|
217
|
+
const setResizeObserved = useResizeObserver(([entry]) => {
|
|
218
|
+
if (!resizeDelta) {
|
|
219
|
+
const [box] = entry.borderBoxSize;
|
|
220
|
+
setPixelSize({
|
|
221
|
+
width: box.inlineSize,
|
|
222
|
+
height: box.blockSize
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// This is usually 0 unless the image height is less than the line-height.
|
|
226
|
+
setOffsetTop(entry.target.offsetTop);
|
|
227
|
+
});
|
|
228
|
+
const effectResizeableBoxPlacement = useCallback(() => {
|
|
229
|
+
var _imageElement$offsetT;
|
|
230
|
+
setOffsetTop((_imageElement$offsetT = imageElement?.offsetTop) !== null && _imageElement$offsetT !== void 0 ? _imageElement$offsetT : 0);
|
|
231
|
+
}, [imageElement]);
|
|
232
|
+
const setRefs = useMergeRefs([setImageElement, setResizeObserved]);
|
|
218
233
|
const {
|
|
219
234
|
allowResize = true
|
|
220
235
|
} = context;
|
|
221
|
-
const {
|
|
222
|
-
getBlock,
|
|
223
|
-
getSettings
|
|
224
|
-
} = useSelect(blockEditorStore);
|
|
225
236
|
const image = useSelect(select => id && isSingleSelected ? select(coreStore).getMedia(id, {
|
|
226
237
|
context: 'view'
|
|
227
238
|
}) : null, [id, isSingleSelected]);
|
|
@@ -233,7 +244,8 @@ export default function Image({
|
|
|
233
244
|
} = useSelect(select => {
|
|
234
245
|
const {
|
|
235
246
|
getBlockRootClientId,
|
|
236
|
-
canInsertBlockType
|
|
247
|
+
canInsertBlockType,
|
|
248
|
+
getSettings
|
|
237
249
|
} = select(blockEditorStore);
|
|
238
250
|
const rootClientId = getBlockRootClientId(clientId);
|
|
239
251
|
const settings = getSettings();
|
|
@@ -244,6 +256,10 @@ export default function Image({
|
|
|
244
256
|
canInsertCover: canInsertBlockType('core/cover', rootClientId)
|
|
245
257
|
};
|
|
246
258
|
}, [clientId]);
|
|
259
|
+
const {
|
|
260
|
+
getBlock,
|
|
261
|
+
getSettings
|
|
262
|
+
} = useSelect(blockEditorStore);
|
|
247
263
|
const {
|
|
248
264
|
replaceBlocks,
|
|
249
265
|
toggleSelection
|
|
@@ -252,6 +268,9 @@ export default function Image({
|
|
|
252
268
|
createErrorNotice,
|
|
253
269
|
createSuccessNotice
|
|
254
270
|
} = useDispatch(noticesStore);
|
|
271
|
+
const {
|
|
272
|
+
editEntityRecord
|
|
273
|
+
} = useDispatch(coreStore);
|
|
255
274
|
const isLargeViewport = useViewportMatch('medium');
|
|
256
275
|
const isWideAligned = ['wide', 'full'].includes(align);
|
|
257
276
|
const [{
|
|
@@ -290,9 +309,9 @@ export default function Image({
|
|
|
290
309
|
.fetch(url.includes('?') ? url : url + '?').then(response => response.blob()).then(blob => setExternalBlob(blob))
|
|
291
310
|
// Do nothing, cannot upload.
|
|
292
311
|
.catch(() => {});
|
|
293
|
-
}, [id, url, isSingleSelected, externalBlob]);
|
|
312
|
+
}, [id, url, isSingleSelected, externalBlob, getSettings]);
|
|
294
313
|
|
|
295
|
-
// Get naturalWidth and naturalHeight from image
|
|
314
|
+
// Get naturalWidth and naturalHeight from image, and fall back to loaded natural
|
|
296
315
|
// width and height. This resolves an issue in Safari where the loaded natural
|
|
297
316
|
// width and height is otherwise lost when switching between alignments.
|
|
298
317
|
// See: https://github.com/WordPress/gutenberg/pull/37210.
|
|
@@ -301,16 +320,10 @@ export default function Image({
|
|
|
301
320
|
naturalHeight
|
|
302
321
|
} = useMemo(() => {
|
|
303
322
|
return {
|
|
304
|
-
naturalWidth:
|
|
305
|
-
naturalHeight:
|
|
323
|
+
naturalWidth: imageElement?.naturalWidth || loadedNaturalWidth || undefined,
|
|
324
|
+
naturalHeight: imageElement?.naturalHeight || loadedNaturalHeight || undefined
|
|
306
325
|
};
|
|
307
|
-
}, [loadedNaturalWidth, loadedNaturalHeight,
|
|
308
|
-
function onResizeStart() {
|
|
309
|
-
toggleSelection(false);
|
|
310
|
-
}
|
|
311
|
-
function onResizeStop() {
|
|
312
|
-
toggleSelection(true);
|
|
313
|
-
}
|
|
326
|
+
}, [loadedNaturalWidth, loadedNaturalHeight, imageElement?.complete]);
|
|
314
327
|
function onImageError() {
|
|
315
328
|
setHasImageErrored(true);
|
|
316
329
|
|
|
@@ -444,7 +457,21 @@ export default function Image({
|
|
|
444
457
|
!!lightbox && lightbox?.enabled !== lightboxSetting?.enabled || lightboxSetting?.allowEditing;
|
|
445
458
|
const lightboxChecked = !!lightbox?.enabled || !lightbox && !!lightboxSetting?.enabled;
|
|
446
459
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
447
|
-
const dimensionsControl = /*#__PURE__*/_jsx(DimensionsTool, {
|
|
460
|
+
const dimensionsControl = isResizable && (SIZED_LAYOUTS.includes(parentLayoutType) ? /*#__PURE__*/_jsx(DimensionsTool, {
|
|
461
|
+
value: {
|
|
462
|
+
aspectRatio
|
|
463
|
+
},
|
|
464
|
+
onChange: ({
|
|
465
|
+
aspectRatio: newAspectRatio
|
|
466
|
+
}) => {
|
|
467
|
+
setAttributes({
|
|
468
|
+
aspectRatio: newAspectRatio,
|
|
469
|
+
scale: 'cover'
|
|
470
|
+
});
|
|
471
|
+
},
|
|
472
|
+
defaultAspectRatio: "auto",
|
|
473
|
+
tools: ['aspectRatio']
|
|
474
|
+
}) : /*#__PURE__*/_jsx(DimensionsTool, {
|
|
448
475
|
value: {
|
|
449
476
|
width,
|
|
450
477
|
height,
|
|
@@ -475,22 +502,7 @@ export default function Image({
|
|
|
475
502
|
defaultAspectRatio: "auto",
|
|
476
503
|
scaleOptions: scaleOptions,
|
|
477
504
|
unitsOptions: dimensionsUnitsOptions
|
|
478
|
-
});
|
|
479
|
-
const aspectRatioControl = /*#__PURE__*/_jsx(DimensionsTool, {
|
|
480
|
-
value: {
|
|
481
|
-
aspectRatio
|
|
482
|
-
},
|
|
483
|
-
onChange: ({
|
|
484
|
-
aspectRatio: newAspectRatio
|
|
485
|
-
}) => {
|
|
486
|
-
setAttributes({
|
|
487
|
-
aspectRatio: newAspectRatio,
|
|
488
|
-
scale: 'cover'
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
|
-
defaultAspectRatio: "auto",
|
|
492
|
-
tools: ['aspectRatio']
|
|
493
|
-
});
|
|
505
|
+
}));
|
|
494
506
|
const resetAll = () => {
|
|
495
507
|
setAttributes({
|
|
496
508
|
alt: undefined,
|
|
@@ -506,7 +518,7 @@ export default function Image({
|
|
|
506
518
|
label: __('Settings'),
|
|
507
519
|
resetAll: resetAll,
|
|
508
520
|
dropdownMenuProps: dropdownMenuProps,
|
|
509
|
-
children:
|
|
521
|
+
children: dimensionsControl
|
|
510
522
|
})
|
|
511
523
|
});
|
|
512
524
|
const arePatternOverridesEnabled = metadata?.bindings?.__default?.source === 'core/pattern-overrides';
|
|
@@ -658,7 +670,7 @@ export default function Image({
|
|
|
658
670
|
}),
|
|
659
671
|
__nextHasNoMarginBottom: true
|
|
660
672
|
})
|
|
661
|
-
}),
|
|
673
|
+
}), dimensionsControl, !!imageSizeOptions.length && /*#__PURE__*/_jsx(ResolutionTool, {
|
|
662
674
|
value: sizeSlug,
|
|
663
675
|
onChange: updateImage,
|
|
664
676
|
options: imageSizeOptions
|
|
@@ -703,7 +715,6 @@ export default function Image({
|
|
|
703
715
|
queryId
|
|
704
716
|
} = context;
|
|
705
717
|
const isDescendentOfQueryLoop = Number.isFinite(queryId);
|
|
706
|
-
const [, setFeaturedImage] = useEntityProp('postType', postType, 'featured_media', postId);
|
|
707
718
|
let img = temporaryURL && hasImageErrored ?
|
|
708
719
|
/*#__PURE__*/
|
|
709
720
|
// Show a placeholder during upload when the blob URL can't be loaded. This can
|
|
@@ -723,11 +734,19 @@ export default function Image({
|
|
|
723
734
|
alt: defaultedAlt,
|
|
724
735
|
onError: onImageError,
|
|
725
736
|
onLoad: onImageLoad,
|
|
726
|
-
ref:
|
|
737
|
+
ref: setRefs,
|
|
727
738
|
className: borderProps.className,
|
|
739
|
+
width: naturalWidth,
|
|
740
|
+
height: naturalHeight,
|
|
728
741
|
style: {
|
|
729
|
-
|
|
730
|
-
|
|
742
|
+
aspectRatio,
|
|
743
|
+
...(resizeDelta ? {
|
|
744
|
+
width: pixelSize.width + resizeDelta.width,
|
|
745
|
+
height: pixelSize.height + resizeDelta.height
|
|
746
|
+
} : {
|
|
747
|
+
width,
|
|
748
|
+
height
|
|
749
|
+
}),
|
|
731
750
|
objectFit: scale,
|
|
732
751
|
...borderProps.style,
|
|
733
752
|
...shadowProps.style
|
|
@@ -741,8 +760,7 @@ export default function Image({
|
|
|
741
760
|
children: /*#__PURE__*/_jsx(ImageEditor, {
|
|
742
761
|
id: id,
|
|
743
762
|
url: url,
|
|
744
|
-
|
|
745
|
-
height: numericHeight,
|
|
763
|
+
...pixelSize,
|
|
746
764
|
naturalHeight: naturalHeight,
|
|
747
765
|
naturalWidth: naturalWidth,
|
|
748
766
|
onSaveImage: imageAttributes => setAttributes(imageAttributes),
|
|
@@ -752,25 +770,18 @@ export default function Image({
|
|
|
752
770
|
borderProps: isRounded ? undefined : borderProps
|
|
753
771
|
})
|
|
754
772
|
});
|
|
755
|
-
} else if (!isResizable || parentLayoutType === 'grid') {
|
|
756
|
-
img = /*#__PURE__*/_jsx("div", {
|
|
757
|
-
style: {
|
|
758
|
-
width,
|
|
759
|
-
height,
|
|
760
|
-
aspectRatio
|
|
761
|
-
},
|
|
762
|
-
children: /*#__PURE__*/_jsx(ImageWrapper, {
|
|
763
|
-
href: href,
|
|
764
|
-
children: img
|
|
765
|
-
})
|
|
766
|
-
});
|
|
767
773
|
} else {
|
|
774
|
+
img = /*#__PURE__*/_jsx(ImageWrapper, {
|
|
775
|
+
href: href,
|
|
776
|
+
children: img
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
let resizableBox;
|
|
780
|
+
if (isResizable && isSingleSelected && !isEditingImage && !SIZED_LAYOUTS.includes(parentLayoutType)) {
|
|
768
781
|
const numericRatio = aspectRatio && evalAspectRatio(aspectRatio);
|
|
769
|
-
const customRatio =
|
|
782
|
+
const customRatio = pixelSize.width / pixelSize.height;
|
|
770
783
|
const naturalRatio = naturalWidth / naturalHeight;
|
|
771
784
|
const ratio = numericRatio || customRatio || naturalRatio || 1;
|
|
772
|
-
const currentWidth = !numericWidth && numericHeight ? numericHeight * ratio : numericWidth;
|
|
773
|
-
const currentHeight = !numericHeight && numericWidth ? numericWidth / ratio : numericHeight;
|
|
774
785
|
const minWidth = naturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;
|
|
775
786
|
const minHeight = naturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;
|
|
776
787
|
|
|
@@ -813,17 +824,16 @@ export default function Image({
|
|
|
813
824
|
}
|
|
814
825
|
}
|
|
815
826
|
/* eslint-enable no-lonely-if */
|
|
816
|
-
|
|
827
|
+
resizableBox = /*#__PURE__*/_jsx(ResizableBox, {
|
|
828
|
+
ref: effectResizeableBoxPlacement,
|
|
817
829
|
style: {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
830
|
+
position: 'absolute',
|
|
831
|
+
// To match the vertical-align: bottom of the img (from style.scss)
|
|
832
|
+
// syncs the top with the img. This matters when the img height is
|
|
833
|
+
// less than the line-height.
|
|
834
|
+
inset: `${offsetTop}px 0 0 0`
|
|
821
835
|
},
|
|
822
|
-
size:
|
|
823
|
-
width: currentWidth !== null && currentWidth !== void 0 ? currentWidth : 'auto',
|
|
824
|
-
height: currentHeight !== null && currentHeight !== void 0 ? currentHeight : 'auto'
|
|
825
|
-
},
|
|
826
|
-
showHandle: isSingleSelected,
|
|
836
|
+
size: pixelSize,
|
|
827
837
|
minWidth: minWidth,
|
|
828
838
|
maxWidth: maxResizeWidth,
|
|
829
839
|
minHeight: minHeight,
|
|
@@ -835,9 +845,19 @@ export default function Image({
|
|
|
835
845
|
bottom: true,
|
|
836
846
|
left: showLeftHandle
|
|
837
847
|
},
|
|
838
|
-
onResizeStart:
|
|
839
|
-
|
|
840
|
-
|
|
848
|
+
onResizeStart: () => {
|
|
849
|
+
toggleSelection(false);
|
|
850
|
+
},
|
|
851
|
+
onResize: (event, direction, elt, delta) => {
|
|
852
|
+
setResizeDelta(delta);
|
|
853
|
+
},
|
|
854
|
+
onResizeStop: (event, direction, elt, delta) => {
|
|
855
|
+
toggleSelection(true);
|
|
856
|
+
setResizeDelta(null);
|
|
857
|
+
setPixelSize(current => ({
|
|
858
|
+
width: current.width + delta.width,
|
|
859
|
+
height: current.height + delta.height
|
|
860
|
+
}));
|
|
841
861
|
|
|
842
862
|
// Clear hardcoded width if the resized width is close to the max-content width.
|
|
843
863
|
if (maxContentWidth &&
|
|
@@ -861,11 +881,7 @@ export default function Image({
|
|
|
861
881
|
aspectRatio: ratio === naturalRatio ? undefined : String(ratio)
|
|
862
882
|
});
|
|
863
883
|
},
|
|
864
|
-
resizeRatio: align === 'center' ? 2 : 1
|
|
865
|
-
children: /*#__PURE__*/_jsx(ImageWrapper, {
|
|
866
|
-
href: href,
|
|
867
|
-
children: img
|
|
868
|
-
})
|
|
884
|
+
resizeRatio: align === 'center' ? 2 : 1
|
|
869
885
|
});
|
|
870
886
|
}
|
|
871
887
|
if (!url && !temporaryURL) {
|
|
@@ -878,7 +894,9 @@ export default function Image({
|
|
|
878
894
|
* Set the post's featured image with the current image.
|
|
879
895
|
*/
|
|
880
896
|
const setPostFeatureImage = () => {
|
|
881
|
-
|
|
897
|
+
editEntityRecord('postType', postType, postId, {
|
|
898
|
+
featured_media: id
|
|
899
|
+
});
|
|
882
900
|
createSuccessNotice(__('Post featured image updated.'), {
|
|
883
901
|
type: 'snackbar'
|
|
884
902
|
});
|
|
@@ -892,7 +910,7 @@ export default function Image({
|
|
|
892
910
|
})
|
|
893
911
|
});
|
|
894
912
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
895
|
-
children: [mediaReplaceFlow, controls, featuredImageControl, img, /*#__PURE__*/_jsx(Caption, {
|
|
913
|
+
children: [mediaReplaceFlow, controls, featuredImageControl, img, resizableBox, /*#__PURE__*/_jsx(Caption, {
|
|
896
914
|
attributes: attributes,
|
|
897
915
|
setAttributes: setAttributes,
|
|
898
916
|
isSelected: isSingleSelected,
|