@wordpress/block-library 9.11.0 → 9.12.1-next.082ed6819.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 +2 -0
- package/build/block-keyboard-shortcuts/index.js +7 -7
- package/build/block-keyboard-shortcuts/index.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/cover/deprecated.js +140 -4
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +1 -1
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/cover-placeholder.js +1 -2
- package/build/cover/edit/cover-placeholder.js.map +1 -1
- package/build/cover/edit/index.js +23 -23
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/index.js +10 -10
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +13 -13
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +6 -7
- package/build/cover/shared.js.map +1 -1
- package/build/details/index.js +20 -0
- package/build/details/index.js.map +1 -1
- package/build/file/edit.js +8 -4
- package/build/file/edit.js.map +1 -1
- package/build/freeform/modal.js +1 -1
- package/build/freeform/modal.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/heading/index.js +1 -7
- package/build/heading/index.js.map +1 -1
- package/build/home-link/edit.js +20 -36
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +144 -78
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +1 -1
- package/build/latest-posts/edit.js +0 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/navigation/edit/index.js +2 -23
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/use-template-part-area-label.js +6 -8
- package/build/navigation/use-template-part-area-label.js.map +1 -1
- package/build/page-list/index.js +14 -0
- package/build/page-list/index.js.map +1 -1
- package/build/paragraph/edit.js +26 -25
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-content/index.js +13 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-template/edit.js +11 -0
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -13
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js +0 -3
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/edit/query-content.js +10 -12
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +1 -1
- package/build/query/utils.js +38 -9
- package/build/query/utils.js.map +1 -1
- package/build/social-link/edit.js +22 -9
- package/build/social-link/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +2 -7
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +1 -4
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +0 -3
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/get-template-part-icon.js +23 -0
- package/build/template-part/edit/utils/get-template-part-icon.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +1 -6
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/template-part/variations.js +6 -12
- package/build/template-part/variations.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +135 -123
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/block-keyboard-shortcuts/index.js +7 -7
- package/build-module/block-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/cover/deprecated.js +140 -4
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +1 -1
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/cover-placeholder.js +1 -2
- package/build-module/cover/edit/cover-placeholder.js.map +1 -1
- package/build-module/cover/edit/index.js +23 -23
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/index.js +10 -10
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +13 -13
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +6 -7
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/details/index.js +21 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/file/edit.js +8 -4
- package/build-module/file/edit.js.map +1 -1
- package/build-module/freeform/modal.js +1 -1
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/heading/index.js +1 -7
- package/build-module/heading/index.js.map +1 -1
- package/build-module/home-link/edit.js +23 -39
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +149 -83
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +1 -1
- package/build-module/latest-posts/edit.js +0 -1
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/navigation/edit/index.js +2 -23
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/use-template-part-area-label.js +6 -8
- package/build-module/navigation/use-template-part-area-label.js.map +1 -1
- package/build-module/page-list/index.js +14 -0
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/paragraph/edit.js +26 -25
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-content/index.js +13 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-template/edit.js +11 -0
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +3 -13
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js +0 -3
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/edit/query-content.js +10 -12
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +1 -1
- package/build-module/query/utils.js +35 -8
- package/build-module/query/utils.js.map +1 -1
- package/build-module/social-link/edit.js +24 -11
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +3 -8
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -4
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +0 -3
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/get-template-part-icon.js +15 -0
- package/build-module/template-part/edit/utils/get-template-part-icon.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +1 -6
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/template-part/variations.js +5 -11
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +136 -124
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/cover/editor-rtl.css +3 -5
- package/build-style/cover/editor.css +3 -5
- package/build-style/cover/style-rtl.css +19 -15
- package/build-style/cover/style.css +19 -15
- package/build-style/editor-rtl.css +19 -30
- package/build-style/editor.css +19 -30
- package/build-style/group/editor-rtl.css +0 -10
- package/build-style/group/editor.css +0 -10
- package/build-style/image/editor-rtl.css +4 -0
- package/build-style/image/editor.css +4 -0
- package/build-style/image/style-rtl.css +0 -2
- package/build-style/image/style.css +0 -2
- package/build-style/latest-posts/editor-rtl.css +0 -7
- package/build-style/latest-posts/editor.css +0 -7
- package/build-style/media-text/style-rtl.css +1 -1
- package/build-style/media-text/style.css +1 -1
- package/build-style/navigation/style-rtl.css +1 -1
- package/build-style/navigation/style.css +1 -1
- package/build-style/page-list/style-rtl.css +4 -0
- package/build-style/page-list/style.css +4 -0
- package/build-style/query/editor-rtl.css +0 -4
- package/build-style/query/editor.css +0 -4
- package/build-style/search/style-rtl.css +3 -3
- package/build-style/search/style.css +3 -3
- package/build-style/social-link/editor-rtl.css +4 -4
- package/build-style/social-link/editor.css +4 -4
- package/build-style/style-rtl.css +28 -22
- package/build-style/style.css +28 -22
- package/build-style/video/editor-rtl.css +8 -0
- package/build-style/video/editor.css +8 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/package.json +39 -39
- package/src/block-keyboard-shortcuts/index.js +25 -11
- package/src/button/index.js +1 -1
- package/src/comments/block.json +3 -9
- package/src/cover/deprecated.js +182 -4
- package/src/cover/edit/block-controls.js +1 -1
- package/src/cover/edit/cover-placeholder.js +0 -3
- package/src/cover/edit/index.js +42 -27
- package/src/cover/editor.scss +4 -5
- package/src/cover/index.js +8 -8
- package/src/cover/save.js +27 -20
- package/src/cover/shared.js +10 -10
- package/src/cover/style.scss +40 -16
- package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
- package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
- package/src/cover/test/edit.js +2 -2
- package/src/cover/test/edit.native.js +4 -4
- package/src/cover/test/transforms.native.js +4 -4
- package/src/details/block.json +1 -0
- package/src/details/index.js +23 -1
- package/src/file/edit.js +9 -3
- package/src/freeform/modal.js +1 -1
- package/src/gallery/edit.js +1 -1
- package/src/group/editor.scss +0 -12
- package/src/heading/block.json +1 -7
- package/src/home-link/edit.js +27 -45
- package/src/home-link/index.php +0 -3
- package/src/image/block.json +1 -1
- package/src/image/edit.js +1 -1
- package/src/image/editor.scss +4 -0
- package/src/image/image.js +200 -109
- package/src/image/style.scss +0 -1
- package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/latest-posts/edit.js +0 -1
- package/src/latest-posts/editor.scss +0 -11
- package/src/media-text/style.scss +1 -1
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/navigation/edit/index.js +3 -30
- package/src/navigation/index.php +5 -151
- package/src/navigation/style.scss +1 -1
- package/src/navigation/use-template-part-area-label.js +10 -10
- package/src/page-list/block.json +14 -0
- package/src/page-list/style.scss +4 -0
- package/src/paragraph/edit.js +20 -17
- package/src/pattern/index.php +0 -7
- package/src/post-content/block.json +14 -1
- package/src/post-template/block.json +2 -1
- package/src/post-template/edit.js +19 -0
- package/src/query/block.json +1 -1
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -5
- package/src/query/edit/inspector-controls/index.js +2 -12
- package/src/query/edit/pattern-selection-modal.js +0 -3
- package/src/query/edit/query-content.js +9 -17
- package/src/query/editor.scss +0 -4
- package/src/query/index.php +1 -1
- package/src/query/test/utils.js +59 -1
- package/src/query/utils.js +43 -15
- package/src/rss/index.php +11 -8
- package/src/search/index.php +2 -2
- package/src/search/style.scss +3 -5
- package/src/social-link/edit.js +47 -19
- package/src/social-link/editor.scss +6 -7
- package/src/template-part/edit/advanced-controls.js +13 -13
- package/src/template-part/edit/index.js +1 -4
- package/src/template-part/edit/selection-modal.js +0 -3
- package/src/template-part/edit/utils/get-template-part-icon.js +20 -0
- package/src/template-part/edit/utils/hooks.js +2 -7
- package/src/template-part/variations.js +4 -16
- package/src/video/edit.js +1 -1
- package/src/video/editor.scss +9 -0
- package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/video/tracks-editor.js +157 -141
- package/tsconfig.tsbuildinfo +1 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js +0 -40
- package/build/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js +0 -33
- package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
- package/src/query/edit/inspector-controls/create-new-post-link.js +0 -32
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -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'Upload or drag an image file here, or pick one 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,mBAAmB,QACb,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,IAAI,EAAEC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AACxE,SAASf,KAAK,IAAIgB,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,iBAAiB,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,SAASC,yBAAyB,QAAQ,gBAAgB;AAC1D,OAAOC,KAAK,MAAM,SAAS;AAC3B,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,mBAAmB,QAAQ,0BAA0B;;AAE9D;AACA;AACA;AACA,SACCC,2BAA2B,EAC3BC,uBAAuB,EACvBC,sBAAsB,EACtBC,qBAAqB,EACrBC,mBAAmB,QACb,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAErB,OAAO,MAA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sx","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,mBAAmB,QACb,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,IAAI,EAAEC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AACxE,SAASf,KAAK,IAAIgB,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,iBAAiB,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,SAASC,yBAAyB,QAAQ,gBAAgB;AAC1D,OAAOC,KAAK,MAAM,SAAS;AAC3B,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,mBAAmB,QAAQ,0BAA0B;;AAE9D;AACA;AACA;AACA,SACCC,2BAA2B,EAC3BC,uBAAuB,EACvBC,sBAAsB,EACtBC,qBAAqB,EACrBC,mBAAmB,QACb,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAErB,OAAO,MAAMC,sBAAsB,GAAGA,CAAErB,KAAK,EAAEsB,IAAI,KAAM;EACxD,MAAMC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'@wordpress/blob';
|
|
5
|
-
import { ExternalLink, ResizableBox, Spinner, TextareaControl, TextControl, ToolbarButton, ToolbarGroup,
|
|
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
6
|
import { useViewportMatch } from '@wordpress/compose';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import { BlockControls, InspectorControls, __experimentalImageURLInputUI as ImageURLInputUI, MediaReplaceFlow, store as blockEditorStore, useSettings, __experimentalImageEditor as ImageEditor, __experimentalUseBorderProps as useBorderProps, __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
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
9
|
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
|
|
10
10
|
import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
|
|
11
|
-
import { DOWN } from '@wordpress/keycodes';
|
|
12
11
|
import { getFilename } from '@wordpress/url';
|
|
13
12
|
import { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';
|
|
14
|
-
import { crop, overlayText, upload } from '@wordpress/icons';
|
|
13
|
+
import { crop, overlayText, upload, chevronDown } from '@wordpress/icons';
|
|
15
14
|
import { store as noticesStore } from '@wordpress/notices';
|
|
16
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
15
|
+
import { store as coreStore, useEntityProp } from '@wordpress/core-data';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Internal dependencies
|
|
@@ -29,7 +28,7 @@ import { Caption } from '../utils/caption';
|
|
|
29
28
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
30
29
|
import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
|
|
31
30
|
import { evalAspectRatio } from './utils';
|
|
32
|
-
import { jsx as _jsx,
|
|
31
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
32
|
const {
|
|
34
33
|
DimensionsTool,
|
|
35
34
|
ResolutionTool
|
|
@@ -43,6 +42,9 @@ const scaleOptions = [{
|
|
|
43
42
|
label: _x('Contain', 'Scale option for dimensions control'),
|
|
44
43
|
help: __('Image is contained without distortion.')
|
|
45
44
|
}];
|
|
45
|
+
const WRITEMODE_POPOVER_PROPS = {
|
|
46
|
+
placement: 'bottom-start'
|
|
47
|
+
};
|
|
46
48
|
|
|
47
49
|
// If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles.
|
|
48
50
|
const ImageWrapper = ({
|
|
@@ -68,6 +70,111 @@ const ImageWrapper = ({
|
|
|
68
70
|
children: children
|
|
69
71
|
});
|
|
70
72
|
};
|
|
73
|
+
function ContentOnlyControls({
|
|
74
|
+
attributes,
|
|
75
|
+
setAttributes,
|
|
76
|
+
lockAltControls,
|
|
77
|
+
lockAltControlsMessage,
|
|
78
|
+
lockTitleControls,
|
|
79
|
+
lockTitleControlsMessage
|
|
80
|
+
}) {
|
|
81
|
+
// Use internal state instead of a ref to make sure that the component
|
|
82
|
+
// re-renders when the popover's anchor updates.
|
|
83
|
+
const [popoverAnchor, setPopoverAnchor] = useState(null);
|
|
84
|
+
const [isAltDialogOpen, setIsAltDialogOpen] = useState(false);
|
|
85
|
+
const [isTitleDialogOpen, setIsTitleDialogOpen] = useState(false);
|
|
86
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
87
|
+
children: [/*#__PURE__*/_jsx(ToolbarItem, {
|
|
88
|
+
ref: setPopoverAnchor,
|
|
89
|
+
children: toggleProps => /*#__PURE__*/_jsx(DropdownMenu, {
|
|
90
|
+
icon: chevronDown
|
|
91
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
92
|
+
label: __('More'),
|
|
93
|
+
toggleProps: {
|
|
94
|
+
...toggleProps,
|
|
95
|
+
description: __('Displays more controls.')
|
|
96
|
+
},
|
|
97
|
+
popoverProps: WRITEMODE_POPOVER_PROPS,
|
|
98
|
+
children: ({
|
|
99
|
+
onClose
|
|
100
|
+
}) => /*#__PURE__*/_jsxs(_Fragment, {
|
|
101
|
+
children: [/*#__PURE__*/_jsx(MenuItem, {
|
|
102
|
+
onClick: () => {
|
|
103
|
+
setIsAltDialogOpen(true);
|
|
104
|
+
onClose();
|
|
105
|
+
},
|
|
106
|
+
"aria-haspopup": "dialog",
|
|
107
|
+
children: _x('Alternative text', 'Alternative text for an image. Block toolbar label, a low character count is preferred.')
|
|
108
|
+
}), /*#__PURE__*/_jsx(MenuItem, {
|
|
109
|
+
onClick: () => {
|
|
110
|
+
setIsTitleDialogOpen(true);
|
|
111
|
+
onClose();
|
|
112
|
+
},
|
|
113
|
+
"aria-haspopup": "dialog",
|
|
114
|
+
children: __('Title text')
|
|
115
|
+
})]
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
}), isAltDialogOpen && /*#__PURE__*/_jsx(Popover, {
|
|
119
|
+
placement: "bottom-start",
|
|
120
|
+
anchor: popoverAnchor,
|
|
121
|
+
onClose: () => setIsAltDialogOpen(false),
|
|
122
|
+
offset: 13,
|
|
123
|
+
variant: "toolbar",
|
|
124
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
125
|
+
className: "wp-block-image__toolbar_content_textarea__container",
|
|
126
|
+
children: /*#__PURE__*/_jsx(TextareaControl, {
|
|
127
|
+
className: "wp-block-image__toolbar_content_textarea",
|
|
128
|
+
label: __('Alternative text'),
|
|
129
|
+
value: attributes.alt || '',
|
|
130
|
+
onChange: value => setAttributes({
|
|
131
|
+
alt: value
|
|
132
|
+
}),
|
|
133
|
+
disabled: lockAltControls,
|
|
134
|
+
help: lockAltControls ? /*#__PURE__*/_jsx(_Fragment, {
|
|
135
|
+
children: lockAltControlsMessage
|
|
136
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
137
|
+
children: [/*#__PURE__*/_jsx(ExternalLink, {
|
|
138
|
+
href:
|
|
139
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
140
|
+
__('https://www.w3.org/WAI/tutorials/images/decision-tree/'),
|
|
141
|
+
children: __('Describe the purpose of the image.')
|
|
142
|
+
}), /*#__PURE__*/_jsx("br", {}), __('Leave empty if decorative.')]
|
|
143
|
+
}),
|
|
144
|
+
__nextHasNoMarginBottom: true
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
}), isTitleDialogOpen && /*#__PURE__*/_jsx(Popover, {
|
|
148
|
+
placement: "bottom-start",
|
|
149
|
+
anchor: popoverAnchor,
|
|
150
|
+
onClose: () => setIsTitleDialogOpen(false),
|
|
151
|
+
offset: 13,
|
|
152
|
+
variant: "toolbar",
|
|
153
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
154
|
+
className: "wp-block-image__toolbar_content_textarea__container",
|
|
155
|
+
children: /*#__PURE__*/_jsx(TextControl, {
|
|
156
|
+
__next40pxDefaultSize: true,
|
|
157
|
+
className: "wp-block-image__toolbar_content_textarea",
|
|
158
|
+
__nextHasNoMarginBottom: true,
|
|
159
|
+
label: __('Title attribute'),
|
|
160
|
+
value: attributes.title || '',
|
|
161
|
+
onChange: value => setAttributes({
|
|
162
|
+
title: value
|
|
163
|
+
}),
|
|
164
|
+
disabled: lockTitleControls,
|
|
165
|
+
help: lockTitleControls ? /*#__PURE__*/_jsx(_Fragment, {
|
|
166
|
+
children: lockTitleControlsMessage
|
|
167
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
168
|
+
children: [__('Describe the role of this image on the page.'), /*#__PURE__*/_jsx(ExternalLink, {
|
|
169
|
+
href: "https://www.w3.org/TR/html52/dom.html#the-title-attribute",
|
|
170
|
+
children: __('(Note: many devices and browsers do not display this text.)')
|
|
171
|
+
})]
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
})]
|
|
176
|
+
});
|
|
177
|
+
}
|
|
71
178
|
export default function Image({
|
|
72
179
|
temporaryURL,
|
|
73
180
|
attributes,
|
|
@@ -512,82 +619,16 @@ export default function Image({
|
|
|
512
619
|
// Add some extra controls for content attributes when content only mode is active.
|
|
513
620
|
// With content only mode active, the inspector is hidden, so users need another way
|
|
514
621
|
// to edit these attributes.
|
|
515
|
-
|
|
516
|
-
group: "
|
|
517
|
-
children:
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
onClick: onToggle,
|
|
526
|
-
"aria-haspopup": "true",
|
|
527
|
-
"aria-expanded": isOpen,
|
|
528
|
-
onKeyDown: event => {
|
|
529
|
-
if (!isOpen && event.keyCode === DOWN) {
|
|
530
|
-
event.preventDefault();
|
|
531
|
-
onToggle();
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
children: _x('Alternative text', 'Alternative text for an image. Block toolbar label, a low character count is preferred.')
|
|
535
|
-
}),
|
|
536
|
-
renderContent: () => /*#__PURE__*/_jsx(TextareaControl, {
|
|
537
|
-
className: "wp-block-image__toolbar_content_textarea",
|
|
538
|
-
label: __('Alternative text'),
|
|
539
|
-
value: alt || '',
|
|
540
|
-
onChange: updateAlt,
|
|
541
|
-
disabled: lockAltControls,
|
|
542
|
-
help: lockAltControls ? /*#__PURE__*/_jsx(_Fragment, {
|
|
543
|
-
children: lockAltControlsMessage
|
|
544
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
545
|
-
children: [/*#__PURE__*/_jsx(ExternalLink, {
|
|
546
|
-
href:
|
|
547
|
-
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
548
|
-
__('https://www.w3.org/WAI/tutorials/images/decision-tree/'),
|
|
549
|
-
children: __('Describe the purpose of the image.')
|
|
550
|
-
}), /*#__PURE__*/_jsx("br", {}), __('Leave empty if decorative.')]
|
|
551
|
-
}),
|
|
552
|
-
__nextHasNoMarginBottom: true
|
|
553
|
-
})
|
|
554
|
-
}), title && /*#__PURE__*/_jsx(Dropdown, {
|
|
555
|
-
popoverProps: {
|
|
556
|
-
position: 'bottom right'
|
|
557
|
-
},
|
|
558
|
-
renderToggle: ({
|
|
559
|
-
isOpen,
|
|
560
|
-
onToggle
|
|
561
|
-
}) => /*#__PURE__*/_jsx(ToolbarButton, {
|
|
562
|
-
onClick: onToggle,
|
|
563
|
-
"aria-haspopup": "true",
|
|
564
|
-
"aria-expanded": isOpen,
|
|
565
|
-
onKeyDown: event => {
|
|
566
|
-
if (!isOpen && event.keyCode === DOWN) {
|
|
567
|
-
event.preventDefault();
|
|
568
|
-
onToggle();
|
|
569
|
-
}
|
|
570
|
-
},
|
|
571
|
-
children: __('Title')
|
|
572
|
-
}),
|
|
573
|
-
renderContent: () => /*#__PURE__*/_jsx(TextControl, {
|
|
574
|
-
__next40pxDefaultSize: true,
|
|
575
|
-
className: "wp-block-image__toolbar_content_textarea",
|
|
576
|
-
__nextHasNoMarginBottom: true,
|
|
577
|
-
label: __('Title attribute'),
|
|
578
|
-
value: title || '',
|
|
579
|
-
onChange: onSetTitle,
|
|
580
|
-
disabled: lockTitleControls,
|
|
581
|
-
help: lockTitleControls ? /*#__PURE__*/_jsx(_Fragment, {
|
|
582
|
-
children: lockTitleControlsMessage
|
|
583
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
584
|
-
children: [__('Describe the role of this image on the page.'), /*#__PURE__*/_jsx(ExternalLink, {
|
|
585
|
-
href: "https://www.w3.org/TR/html52/dom.html#the-title-attribute",
|
|
586
|
-
children: __('(Note: many devices and browsers do not display this text.)')
|
|
587
|
-
})]
|
|
588
|
-
})
|
|
589
|
-
})
|
|
590
|
-
})]
|
|
622
|
+
_jsx(BlockControls, {
|
|
623
|
+
group: "block",
|
|
624
|
+
children: /*#__PURE__*/_jsx(ContentOnlyControls, {
|
|
625
|
+
attributes: attributes,
|
|
626
|
+
setAttributes: setAttributes,
|
|
627
|
+
lockAltControls: lockAltControls,
|
|
628
|
+
lockAltControlsMessage: lockAltControlsMessage,
|
|
629
|
+
lockTitleControls: lockTitleControls,
|
|
630
|
+
lockTitleControlsMessage: lockTitleControlsMessage
|
|
631
|
+
})
|
|
591
632
|
}), /*#__PURE__*/_jsx(InspectorControls, {
|
|
592
633
|
children: /*#__PURE__*/_jsxs(ToolsPanel, {
|
|
593
634
|
label: __('Settings'),
|
|
@@ -656,6 +697,13 @@ export default function Image({
|
|
|
656
697
|
const borderProps = useBorderProps(attributes);
|
|
657
698
|
const shadowProps = getShadowClassesAndStyles(attributes);
|
|
658
699
|
const isRounded = attributes.className?.includes('is-style-rounded');
|
|
700
|
+
const {
|
|
701
|
+
postType,
|
|
702
|
+
postId,
|
|
703
|
+
queryId
|
|
704
|
+
} = context;
|
|
705
|
+
const isDescendentOfQueryLoop = Number.isFinite(queryId);
|
|
706
|
+
const [, setFeaturedImage] = useEntityProp('postType', postType, 'featured_media', postId);
|
|
659
707
|
let img = temporaryURL && hasImageErrored ?
|
|
660
708
|
/*#__PURE__*/
|
|
661
709
|
// Show a placeholder during upload when the blob URL can't be loaded. This can
|
|
@@ -825,8 +873,26 @@ export default function Image({
|
|
|
825
873
|
children: [mediaReplaceFlow, metadata?.bindings ? controls : sizeControls]
|
|
826
874
|
});
|
|
827
875
|
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Set the post's featured image with the current image.
|
|
879
|
+
*/
|
|
880
|
+
const setPostFeatureImage = () => {
|
|
881
|
+
setFeaturedImage(id);
|
|
882
|
+
createSuccessNotice(__('Post featured image updated.'), {
|
|
883
|
+
type: 'snackbar'
|
|
884
|
+
});
|
|
885
|
+
};
|
|
886
|
+
const featuredImageControl = /*#__PURE__*/_jsx(BlockSettingsMenuControls, {
|
|
887
|
+
children: ({
|
|
888
|
+
selectedClientIds
|
|
889
|
+
}) => selectedClientIds.length === 1 && !isDescendentOfQueryLoop && postId && id && clientId === selectedClientIds[0] && /*#__PURE__*/_jsx(MenuItem, {
|
|
890
|
+
onClick: setPostFeatureImage,
|
|
891
|
+
children: __('Set featured image')
|
|
892
|
+
})
|
|
893
|
+
});
|
|
828
894
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
829
|
-
children: [mediaReplaceFlow, controls, img, /*#__PURE__*/_jsx(Caption, {
|
|
895
|
+
children: [mediaReplaceFlow, controls, featuredImageControl, img, /*#__PURE__*/_jsx(Caption, {
|
|
830
896
|
attributes: attributes,
|
|
831
897
|
setAttributes: setAttributes,
|
|
832
898
|
isSelected: isSingleSelected,
|