@wordpress/block-library 9.44.0 → 9.44.1-next.v.202604201441.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/build/button/constants.cjs +1 -1
- package/build/button/constants.cjs.map +1 -1
- package/build/group/block.json +2 -1
- package/build/image/constants.cjs +1 -1
- package/build/image/constants.cjs.map +2 -2
- package/build/image/edit.cjs +1 -3
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +20 -9
- package/build/image/image.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +1 -1
- package/build/latest-posts/edit.cjs.map +1 -1
- package/build/paragraph/use-enter.cjs +12 -23
- package/build/paragraph/use-enter.cjs.map +2 -2
- package/build/post-featured-image/edit.cjs +2 -5
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-template/edit.cjs +8 -2
- package/build/post-template/edit.cjs.map +2 -2
- package/build/pullquote/block.json +1 -4
- package/build/site-logo/edit.cjs +2 -2
- package/build/site-logo/edit.cjs.map +1 -1
- package/build/tab/block.json +2 -2
- package/build/tab/edit.cjs +3 -21
- package/build/tab/edit.cjs.map +3 -3
- package/build/tab-panel/block.json +1 -1
- package/build/tab-panel/edit.cjs +1 -4
- package/build/tab-panel/edit.cjs.map +2 -2
- package/build/tabs/block.json +0 -1
- package/build/tabs/edit.cjs +10 -86
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/use-tab-menu-sync.cjs +192 -0
- package/build/tabs/use-tab-menu-sync.cjs.map +7 -0
- package/build/tabs-menu/block.json +1 -1
- package/build/tabs-menu/edit.cjs +5 -10
- package/build/tabs-menu/edit.cjs.map +3 -3
- package/build/tabs-menu-item/block.json +1 -4
- package/build/tabs-menu-item/edit.cjs +3 -12
- package/build/tabs-menu-item/edit.cjs.map +2 -2
- package/build-module/button/constants.mjs +1 -1
- package/build-module/button/constants.mjs.map +1 -1
- package/build-module/group/block.json +2 -1
- package/build-module/image/constants.mjs +1 -1
- package/build-module/image/constants.mjs.map +2 -2
- package/build-module/image/edit.mjs +1 -3
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +20 -9
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +1 -1
- package/build-module/latest-posts/edit.mjs.map +1 -1
- package/build-module/paragraph/use-enter.mjs +13 -23
- package/build-module/paragraph/use-enter.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs +2 -5
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-template/edit.mjs +8 -2
- package/build-module/post-template/edit.mjs.map +2 -2
- package/build-module/pullquote/block.json +1 -4
- package/build-module/site-logo/edit.mjs +2 -2
- package/build-module/site-logo/edit.mjs.map +1 -1
- package/build-module/tab/block.json +2 -2
- package/build-module/tab/edit.mjs +3 -21
- package/build-module/tab/edit.mjs.map +2 -2
- package/build-module/tab-panel/block.json +1 -1
- package/build-module/tab-panel/edit.mjs +1 -4
- package/build-module/tab-panel/edit.mjs.map +2 -2
- package/build-module/tabs/block.json +0 -1
- package/build-module/tabs/edit.mjs +12 -88
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/use-tab-menu-sync.mjs +171 -0
- package/build-module/tabs/use-tab-menu-sync.mjs.map +7 -0
- package/build-module/tabs-menu/block.json +1 -1
- package/build-module/tabs-menu/edit.mjs +5 -10
- package/build-module/tabs-menu/edit.mjs.map +2 -2
- package/build-module/tabs-menu-item/block.json +1 -4
- package/build-module/tabs-menu-item/edit.mjs +3 -12
- package/build-module/tabs-menu-item/edit.mjs.map +2 -2
- package/build-style/latest-comments/style-rtl.css +4 -4
- package/build-style/latest-comments/style.css +4 -4
- package/build-style/post-template/style-rtl.css +1 -1
- package/build-style/post-template/style.css +1 -1
- package/build-style/style-rtl.css +5 -8
- package/build-style/style.css +5 -8
- package/build-style/tabs/style-rtl.css +0 -3
- package/build-style/tabs/style.css +0 -3
- package/package.json +38 -38
- package/src/block/test/edit.native.js +1 -1
- package/src/button/constants.js +1 -1
- package/src/button/test/get-updated-link-attributes.js +6 -10
- package/src/group/block.json +2 -1
- package/src/image/constants.js +1 -1
- package/src/image/edit.js +0 -2
- package/src/image/image.js +33 -22
- package/src/image/test/edit.native.js +2 -2
- package/src/latest-comments/style.scss +7 -7
- package/src/latest-posts/edit.js +1 -1
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/test/overlay-template-part-selector.js +1 -0
- package/src/paragraph/use-enter.js +18 -24
- package/src/post-featured-image/edit.js +2 -9
- package/src/post-template/edit.js +7 -1
- package/src/post-template/index.php +3 -0
- package/src/post-template/style.scss +2 -2
- package/src/pullquote/block.json +1 -4
- package/src/site-logo/edit.js +2 -2
- package/src/tab/block.json +2 -2
- package/src/tab/edit.js +2 -27
- package/src/tab-panel/block.json +1 -1
- package/src/tab-panel/edit.js +2 -4
- package/src/tabs/block.json +0 -1
- package/src/tabs/edit.js +11 -134
- package/src/tabs/style.scss +0 -3
- package/src/tabs/use-tab-menu-sync.js +239 -0
- package/src/tabs-menu/block.json +1 -1
- package/src/tabs-menu/edit.js +6 -15
- package/src/tabs-menu-item/block.json +1 -4
- package/src/tabs-menu-item/edit.js +3 -12
- package/build/tab/slug-from-label.cjs +0 -37
- package/build/tab/slug-from-label.cjs.map +0 -7
- package/build-module/tab/slug-from-label.mjs +0 -16
- package/build-module/tab/slug-from-label.mjs.map +0 -7
- package/src/tab/slug-from-label.js +0 -26
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/latest-posts/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlaceholder,\n\tQueryControls,\n\tRadioControl,\n\tRangeControl,\n\tSpinner,\n\tToggleControl,\n\tToolbarGroup,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { dateI18n, format, getSettings } from '@wordpress/date';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\t__experimentalImageSizeControl as ImageSizeControl,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tpin,\n\tlist,\n\tgrid,\n\talignNone,\n\tpositionLeft,\n\tpositionCenter,\n\tpositionRight,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticeStore } from '@wordpress/notices';\nimport { useInstanceId } from '@wordpress/compose';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMIN_EXCERPT_LENGTH,\n\tMAX_EXCERPT_LENGTH,\n\tMAX_POSTS_COLUMNS,\n\tDEFAULT_EXCERPT_LENGTH,\n} from './constants';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/**\n * Module Constants\n */\nconst CATEGORIES_LIST_QUERY = {\n\tper_page: -1,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\nconst USERS_LIST_QUERY = {\n\tper_page: -1,\n\thas_published_posts: [ 'post' ],\n\tcontext: 'view',\n};\nconst imageAlignmentOptions = [\n\t{\n\t\tvalue: 'none',\n\t\ticon: alignNone,\n\t\tlabel: __( 'None' ),\n\t},\n\t{\n\t\tvalue: 'left',\n\t\ticon: positionLeft,\n\t\tlabel: __( 'Left' ),\n\t},\n\t{\n\t\tvalue: 'center',\n\t\ticon: positionCenter,\n\t\tlabel: __( 'Center' ),\n\t},\n\t{\n\t\tvalue: 'right',\n\t\ticon: positionRight,\n\t\tlabel: __( 'Right' ),\n\t},\n];\n\nfunction getFeaturedImageDetails( post, size ) {\n\tconst image = post._embedded?.[ 'wp:featuredmedia' ]?.[ '0' ];\n\n\treturn {\n\t\turl:\n\t\t\timage?.media_details?.sizes?.[ size ]?.source_url ??\n\t\t\timage?.source_url,\n\t\talt: image?.alt_text,\n\t};\n}\n\nfunction getCurrentAuthor( post ) {\n\treturn post._embedded?.author?.[ 0 ];\n}\n\nfunction Controls( { attributes, setAttributes, postCount } ) {\n\tconst {\n\t\tpostsToShow,\n\t\torder,\n\t\torderBy,\n\t\tcategories,\n\t\tselectedAuthor,\n\t\tdisplayFeaturedImage,\n\t\tdisplayPostContentRadio,\n\t\tdisplayPostContent,\n\t\tdisplayPostDate,\n\t\tdisplayAuthor,\n\t\tpostLayout,\n\t\tcolumns,\n\t\texcerptLength,\n\t\tfeaturedImageAlign,\n\t\tfeaturedImageSizeSlug,\n\t\tfeaturedImageSizeWidth,\n\t\tfeaturedImageSizeHeight,\n\t\taddLinkToFeaturedImage,\n\t} = attributes;\n\tconst {\n\t\timageSizes,\n\t\tdefaultImageWidth,\n\t\tdefaultImageHeight,\n\t\tcategoriesList,\n\t\tauthorList,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getUsers } = select( coreStore );\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\treturn {\n\t\t\t\tdefaultImageWidth:\n\t\t\t\t\tsettings.imageDimensions?.[ featuredImageSizeSlug ]\n\t\t\t\t\t\t?.width ?? 0,\n\t\t\t\tdefaultImageHeight:\n\t\t\t\t\tsettings.imageDimensions?.[ featuredImageSizeSlug ]\n\t\t\t\t\t\t?.height ?? 0,\n\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\tcategoriesList: getEntityRecords(\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\t'category',\n\t\t\t\t\tCATEGORIES_LIST_QUERY\n\t\t\t\t),\n\t\t\t\tauthorList: getUsers( USERS_LIST_QUERY ),\n\t\t\t};\n\t\t},\n\t\t[ featuredImageSizeSlug ]\n\t);\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => slug !== 'full' )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\tconst categorySuggestions =\n\t\tcategoriesList?.reduce(\n\t\t\t( accumulator, category ) => ( {\n\t\t\t\t...accumulator,\n\t\t\t\t[ category.name ]: category,\n\t\t\t} ),\n\t\t\t{}\n\t\t) ?? {};\n\tconst selectCategories = ( tokens ) => {\n\t\tconst hasNoSuggestion = tokens.some(\n\t\t\t( token ) =>\n\t\t\t\ttypeof token === 'string' && ! categorySuggestions[ token ]\n\t\t);\n\t\tif ( hasNoSuggestion ) {\n\t\t\treturn;\n\t\t}\n\t\t// Categories that are already will be objects, while new additions will be strings (the name).\n\t\t// allCategories nomalizes the array so that they are all objects.\n\t\tconst allCategories = tokens.map( ( token ) => {\n\t\t\treturn typeof token === 'string'\n\t\t\t\t? categorySuggestions[ token ]\n\t\t\t\t: token;\n\t\t} );\n\t\t// We do nothing if the category is not selected\n\t\t// from suggestions.\n\t\tif ( allCategories.includes( null ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tsetAttributes( { categories: allCategories } );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Post content' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tdisplayPostContent: false,\n\t\t\t\t\t\tdisplayPostContentRadio: 'excerpt',\n\t\t\t\t\t\texcerptLength: DEFAULT_EXCERPT_LENGTH,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayPostContent }\n\t\t\t\t\tlabel={ __( 'Display post content' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayPostContent: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display post content' ) }\n\t\t\t\t\t\tchecked={ displayPostContent }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayPostContent: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t{ displayPostContent && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => displayPostContentRadio !== 'excerpt' }\n\t\t\t\t\t\tlabel={ __( 'Content length' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayPostContentRadio: 'excerpt',\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\tlabel={ __( 'Content length' ) }\n\t\t\t\t\t\t\tselected={ displayPostContentRadio }\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ label: __( 'Excerpt' ), value: 'excerpt' },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Full post' ),\n\t\t\t\t\t\t\t\t\tvalue: 'full_post',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdisplayPostContentRadio: value,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ displayPostContent &&\n\t\t\t\t\tdisplayPostContentRadio === 'excerpt' && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\texcerptLength !== DEFAULT_EXCERPT_LENGTH\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\texcerptLength: DEFAULT_EXCERPT_LENGTH,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\t\t\tvalue={ excerptLength }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { excerptLength: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmin={ MIN_EXCERPT_LENGTH }\n\t\t\t\t\t\t\t\tmax={ MAX_EXCERPT_LENGTH }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Post meta' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tdisplayAuthor: false,\n\t\t\t\t\t\tdisplayPostDate: false,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayAuthor }\n\t\t\t\t\tlabel={ __( 'Display author name' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayAuthor: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display author name' ) }\n\t\t\t\t\t\tchecked={ displayAuthor }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayAuthor: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayPostDate }\n\t\t\t\t\tlabel={ __( 'Display post date' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayPostDate: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display post date' ) }\n\t\t\t\t\t\tchecked={ displayPostDate }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayPostDate: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Featured image' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tdisplayFeaturedImage: false,\n\t\t\t\t\t\tfeaturedImageAlign: undefined,\n\t\t\t\t\t\tfeaturedImageSizeSlug: 'thumbnail',\n\t\t\t\t\t\tfeaturedImageSizeWidth: null,\n\t\t\t\t\t\tfeaturedImageSizeHeight: null,\n\t\t\t\t\t\taddLinkToFeaturedImage: false,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayFeaturedImage }\n\t\t\t\t\tlabel={ __( 'Display featured image' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayFeaturedImage: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display featured image' ) }\n\t\t\t\t\t\tchecked={ displayFeaturedImage }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayFeaturedImage: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t{ displayFeaturedImage && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\tfeaturedImageSizeSlug !== 'thumbnail' ||\n\t\t\t\t\t\t\t\tfeaturedImageSizeWidth !== null ||\n\t\t\t\t\t\t\t\tfeaturedImageSizeHeight !== null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tfeaturedImageSizeSlug: 'thumbnail',\n\t\t\t\t\t\t\t\t\tfeaturedImageSizeWidth: null,\n\t\t\t\t\t\t\t\t\tfeaturedImageSizeHeight: null,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ImageSizeControl\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tconst newAttrs = {};\n\t\t\t\t\t\t\t\t\tif ( value.hasOwnProperty( 'width' ) ) {\n\t\t\t\t\t\t\t\t\t\tnewAttrs.featuredImageSizeWidth =\n\t\t\t\t\t\t\t\t\t\t\tvalue.width;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( value.hasOwnProperty( 'height' ) ) {\n\t\t\t\t\t\t\t\t\t\tnewAttrs.featuredImageSizeHeight =\n\t\t\t\t\t\t\t\t\t\t\tvalue.height;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetAttributes( newAttrs );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tslug={ featuredImageSizeSlug }\n\t\t\t\t\t\t\t\twidth={ featuredImageSizeWidth }\n\t\t\t\t\t\t\t\theight={ featuredImageSizeHeight }\n\t\t\t\t\t\t\t\timageWidth={ defaultImageWidth }\n\t\t\t\t\t\t\t\timageHeight={ defaultImageHeight }\n\t\t\t\t\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t\t\t\t\t\timageSizeHelp={ __(\n\t\t\t\t\t\t\t\t\t'Select the size of the source image.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChangeImage={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tfeaturedImageSizeSlug: value,\n\t\t\t\t\t\t\t\t\t\tfeaturedImageSizeWidth: undefined,\n\t\t\t\t\t\t\t\t\t\tfeaturedImageSizeHeight: undefined,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! featuredImageAlign }\n\t\t\t\t\t\t\tlabel={ __( 'Image alignment' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tfeaturedImageAlign: undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t\tclassName=\"editor-latest-posts-image-alignment-control\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Image alignment' ) }\n\t\t\t\t\t\t\t\tvalue={ featuredImageAlign || 'none' }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tfeaturedImageAlign:\n\t\t\t\t\t\t\t\t\t\t\tvalue !== 'none'\n\t\t\t\t\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ imageAlignmentOptions.map(\n\t\t\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! addLinkToFeaturedImage }\n\t\t\t\t\t\t\tlabel={ __( 'Add link to featured image' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\taddLinkToFeaturedImage: false,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Add link to featured image' ) }\n\t\t\t\t\t\t\t\tchecked={ addLinkToFeaturedImage }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\taddLinkToFeaturedImage: value,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Sorting and filtering' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\torder: 'desc',\n\t\t\t\t\t\torderBy: 'date',\n\t\t\t\t\t\tpostsToShow: 5,\n\t\t\t\t\t\tcategories: undefined,\n\t\t\t\t\t\tselectedAuthor: undefined,\n\t\t\t\t\t\tcolumns: 3,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\torder !== 'desc' ||\n\t\t\t\t\t\torderBy !== 'date' ||\n\t\t\t\t\t\tpostsToShow !== 5 ||\n\t\t\t\t\t\tcategories?.length > 0 ||\n\t\t\t\t\t\t!! selectedAuthor\n\t\t\t\t\t}\n\t\t\t\t\tlabel={ __( 'Sort and filter' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\torder: 'desc',\n\t\t\t\t\t\t\torderBy: 'date',\n\t\t\t\t\t\t\tpostsToShow: 5,\n\t\t\t\t\t\t\tcategories: undefined,\n\t\t\t\t\t\t\tselectedAuthor: undefined,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<QueryControls\n\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\tnumberOfItems={ postsToShow }\n\t\t\t\t\t\tonOrderChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { order: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonOrderByChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { orderBy: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonNumberOfItemsChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { postsToShow: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcategorySuggestions={ categorySuggestions }\n\t\t\t\t\t\tonCategoryChange={ selectCategories }\n\t\t\t\t\t\tselectedCategories={ categories }\n\t\t\t\t\t\tonAuthorChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tselectedAuthor:\n\t\t\t\t\t\t\t\t\t'' !== value ? Number( value ) : undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tauthorList={ authorList ?? [] }\n\t\t\t\t\t\tselectedAuthorId={ selectedAuthor }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t{ postLayout === 'grid' && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => columns !== 3 }\n\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tcolumns: 3,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\tvalue={ columns }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { columns: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\t! postCount\n\t\t\t\t\t\t\t\t\t? MAX_POSTS_COLUMNS\n\t\t\t\t\t\t\t\t\t: Math.min( MAX_POSTS_COLUMNS, postCount )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\t\t</>\n\t);\n}\n\nexport default function LatestPostsEdit( { attributes, setAttributes } ) {\n\tconst instanceId = useInstanceId( LatestPostsEdit );\n\n\tconst {\n\t\tpostsToShow,\n\t\torder,\n\t\torderBy,\n\t\tcategories,\n\t\tselectedAuthor,\n\t\tdisplayFeaturedImage,\n\t\tdisplayPostContentRadio,\n\t\tdisplayPostContent,\n\t\tdisplayPostDate,\n\t\tdisplayAuthor,\n\t\tpostLayout,\n\t\tcolumns,\n\t\texcerptLength,\n\t\tfeaturedImageAlign,\n\t\tfeaturedImageSizeSlug,\n\t\tfeaturedImageSizeWidth,\n\t\tfeaturedImageSizeHeight,\n\t\taddLinkToFeaturedImage,\n\t} = attributes;\n\tconst { latestPosts } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst catIds =\n\t\t\t\tcategories && categories.length > 0\n\t\t\t\t\t? categories.map( ( cat ) => cat.id )\n\t\t\t\t\t: [];\n\t\t\tconst latestPostsQuery = Object.fromEntries(\n\t\t\t\tObject.entries( {\n\t\t\t\t\tcategories: catIds,\n\t\t\t\t\tauthor: selectedAuthor,\n\t\t\t\t\torder,\n\t\t\t\t\torderby: orderBy,\n\t\t\t\t\tper_page: postsToShow,\n\t\t\t\t\t_embed: 'author,wp:featuredmedia',\n\t\t\t\t\tignore_sticky: true,\n\t\t\t\t} ).filter( ( [ , value ] ) => typeof value !== 'undefined' )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlatestPosts: getEntityRecords(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'post',\n\t\t\t\t\tlatestPostsQuery\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postsToShow, order, orderBy, categories, selectedAuthor ]\n\t);\n\n\t// If a user clicks to a link prevent redirection and show a warning.\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst hasPosts = !! latestPosts?.length;\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<Controls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tpostCount={ latestPosts?.length ?? 0 }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t'wp-block-latest-posts__list': true,\n\t\t\t'is-grid': postLayout === 'grid',\n\t\t\t'has-dates': displayPostDate,\n\t\t\t'has-author': displayAuthor,\n\t\t\t[ `columns-${ columns }` ]: postLayout === 'grid',\n\t\t} ),\n\t} );\n\n\tif ( ! hasPosts ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ inspectorControls }\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Latest Posts' ) }>\n\t\t\t\t\t{ ! Array.isArray( latestPosts ) ? (\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t__( 'No posts found.' )\n\t\t\t\t\t) }\n\t\t\t\t</Placeholder>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Removing posts from display should be instant.\n\tconst displayPosts =\n\t\tlatestPosts.length > postsToShow\n\t\t\t? latestPosts.slice( 0, postsToShow )\n\t\t\t: latestPosts;\n\n\tconst layoutControls = [\n\t\t{\n\t\t\ticon: list,\n\t\t\ttitle: _x( 'List view', 'Latest posts block display setting' ),\n\t\t\tonClick: () => setAttributes( { postLayout: 'list' } ),\n\t\t\tisActive: postLayout === 'list',\n\t\t},\n\t\t{\n\t\t\ticon: grid,\n\t\t\ttitle: _x( 'Grid view', 'Latest posts block display setting' ),\n\t\t\tonClick: () => setAttributes( { postLayout: 'grid' } ),\n\t\t\tisActive: postLayout === 'grid',\n\t\t},\n\t];\n\n\tconst dateFormat = getSettings().formats.date;\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup controls={ layoutControls } />\n\t\t\t</BlockControls>\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t{ displayPosts.map( ( post ) => {\n\t\t\t\t\tconst titleTrimmed = post.title.rendered.trim();\n\t\t\t\t\tlet excerpt = post.excerpt.rendered;\n\t\t\t\t\tconst currentAuthor = getCurrentAuthor( post );\n\n\t\t\t\t\tconst excerptElement = document.createElement( 'div' );\n\t\t\t\t\texcerptElement.innerHTML = excerpt;\n\n\t\t\t\t\texcerpt =\n\t\t\t\t\t\texcerptElement.textContent ||\n\t\t\t\t\t\texcerptElement.innerText ||\n\t\t\t\t\t\t'';\n\n\t\t\t\t\tconst { url: imageSourceUrl, alt: featuredImageAlt } =\n\t\t\t\t\t\tgetFeaturedImageDetails( post, featuredImageSizeSlug );\n\t\t\t\t\tconst imageClasses = clsx( {\n\t\t\t\t\t\t'wp-block-latest-posts__featured-image': true,\n\t\t\t\t\t\t[ `align${ featuredImageAlign }` ]:\n\t\t\t\t\t\t\t!! featuredImageAlign,\n\t\t\t\t\t} );\n\t\t\t\t\tconst renderFeaturedImage =\n\t\t\t\t\t\tdisplayFeaturedImage && imageSourceUrl;\n\t\t\t\t\tconst featuredImage = renderFeaturedImage && (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tsrc={ imageSourceUrl }\n\t\t\t\t\t\t\talt={ featuredImageAlt }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: featuredImageSizeWidth,\n\t\t\t\t\t\t\t\tmaxHeight: featuredImageSizeHeight,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\n\t\t\t\t\tconst needsReadMore =\n\t\t\t\t\t\texcerptLength < excerpt.trim().split( ' ' ).length &&\n\t\t\t\t\t\tpost.excerpt.raw === '';\n\n\t\t\t\t\tconst postExcerpt = needsReadMore ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ excerpt\n\t\t\t\t\t\t\t\t.trim()\n\t\t\t\t\t\t\t\t.split( ' ', excerptLength )\n\t\t\t\t\t\t\t\t.join( ' ' ) }\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: 1: Hidden accessibility text: Post title */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'\u2026 <a>Read more<span>: %1$s</span></a>'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\ttitleTrimmed || __( '(no title)' )\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__read-more\"\n\t\t\t\t\t\t\t\t\t\t\thref={ post.link }\n\t\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\tshowRedirectionPreventedNotice\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t<span className=\"screen-reader-text\" />\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\texcerpt\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<li key={ post.id }>\n\t\t\t\t\t\t\t{ renderFeaturedImage && (\n\t\t\t\t\t\t\t\t<div className={ imageClasses }>\n\t\t\t\t\t\t\t\t\t{ addLinkToFeaturedImage ? (\n\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\thref={ post.link }\n\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\tshowRedirectionPreventedNotice\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ featuredImage }\n\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\tfeaturedImage\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__post-title\"\n\t\t\t\t\t\t\t\thref={ post.link }\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={\n\t\t\t\t\t\t\t\t\t!! titleTrimmed\n\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t__html: titleTrimmed,\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonClick={ showRedirectionPreventedNotice }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ! titleTrimmed ? __( '(no title)' ) : null }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t{ displayAuthor && currentAuthor && (\n\t\t\t\t\t\t\t\t<div className=\"wp-block-latest-posts__post-author\">\n\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: byline. %s: author. */\n\t\t\t\t\t\t\t\t\t\t__( 'by %s' ),\n\t\t\t\t\t\t\t\t\t\tcurrentAuthor.name\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPostDate && post.date_gmt && (\n\t\t\t\t\t\t\t\t<time\n\t\t\t\t\t\t\t\t\tdateTime={ format( 'c', post.date_gmt ) }\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__post-date\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ dateI18n( dateFormat, post.date_gmt ) }\n\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPostContent &&\n\t\t\t\t\t\t\t\tdisplayPostContentRadio === 'excerpt' && (\n\t\t\t\t\t\t\t\t\t<div className=\"wp-block-latest-posts__post-excerpt\">\n\t\t\t\t\t\t\t\t\t\t{ postExcerpt }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPostContent &&\n\t\t\t\t\t\t\t\tdisplayPostContentRadio === 'full_post' && (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__post-full-content\"\n\t\t\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t\t\t\t__html: post.content.raw.trim(),\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</li>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</>\n\t);\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlaceholder,\n\tQueryControls,\n\tRadioControl,\n\tRangeControl,\n\tSpinner,\n\tToggleControl,\n\tToolbarGroup,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { dateI18n, format, getSettings } from '@wordpress/date';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\t__experimentalImageSizeControl as ImageSizeControl,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tpin,\n\tlist,\n\tgrid,\n\talignNone,\n\tpositionLeft,\n\tpositionCenter,\n\tpositionRight,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticeStore } from '@wordpress/notices';\nimport { useInstanceId } from '@wordpress/compose';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMIN_EXCERPT_LENGTH,\n\tMAX_EXCERPT_LENGTH,\n\tMAX_POSTS_COLUMNS,\n\tDEFAULT_EXCERPT_LENGTH,\n} from './constants';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/**\n * Module Constants\n */\nconst CATEGORIES_LIST_QUERY = {\n\tper_page: -1,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\nconst USERS_LIST_QUERY = {\n\tper_page: -1,\n\thas_published_posts: [ 'post' ],\n\tcontext: 'view',\n};\nconst imageAlignmentOptions = [\n\t{\n\t\tvalue: 'none',\n\t\ticon: alignNone,\n\t\tlabel: __( 'None' ),\n\t},\n\t{\n\t\tvalue: 'left',\n\t\ticon: positionLeft,\n\t\tlabel: __( 'Left' ),\n\t},\n\t{\n\t\tvalue: 'center',\n\t\ticon: positionCenter,\n\t\tlabel: __( 'Center' ),\n\t},\n\t{\n\t\tvalue: 'right',\n\t\ticon: positionRight,\n\t\tlabel: __( 'Right' ),\n\t},\n];\n\nfunction getFeaturedImageDetails( post, size ) {\n\tconst image = post._embedded?.[ 'wp:featuredmedia' ]?.[ '0' ];\n\n\treturn {\n\t\turl:\n\t\t\timage?.media_details?.sizes?.[ size ]?.source_url ??\n\t\t\timage?.source_url,\n\t\talt: image?.alt_text,\n\t};\n}\n\nfunction getCurrentAuthor( post ) {\n\treturn post._embedded?.author?.[ 0 ];\n}\n\nfunction Controls( { attributes, setAttributes, postCount } ) {\n\tconst {\n\t\tpostsToShow,\n\t\torder,\n\t\torderBy,\n\t\tcategories,\n\t\tselectedAuthor,\n\t\tdisplayFeaturedImage,\n\t\tdisplayPostContentRadio,\n\t\tdisplayPostContent,\n\t\tdisplayPostDate,\n\t\tdisplayAuthor,\n\t\tpostLayout,\n\t\tcolumns,\n\t\texcerptLength,\n\t\tfeaturedImageAlign,\n\t\tfeaturedImageSizeSlug,\n\t\tfeaturedImageSizeWidth,\n\t\tfeaturedImageSizeHeight,\n\t\taddLinkToFeaturedImage,\n\t} = attributes;\n\tconst {\n\t\timageSizes,\n\t\tdefaultImageWidth,\n\t\tdefaultImageHeight,\n\t\tcategoriesList,\n\t\tauthorList,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getUsers } = select( coreStore );\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\treturn {\n\t\t\t\tdefaultImageWidth:\n\t\t\t\t\tsettings.imageDimensions?.[ featuredImageSizeSlug ]\n\t\t\t\t\t\t?.width ?? 0,\n\t\t\t\tdefaultImageHeight:\n\t\t\t\t\tsettings.imageDimensions?.[ featuredImageSizeSlug ]\n\t\t\t\t\t\t?.height ?? 0,\n\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\tcategoriesList: getEntityRecords(\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\t'category',\n\t\t\t\t\tCATEGORIES_LIST_QUERY\n\t\t\t\t),\n\t\t\t\tauthorList: getUsers( USERS_LIST_QUERY ),\n\t\t\t};\n\t\t},\n\t\t[ featuredImageSizeSlug ]\n\t);\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => slug !== 'full' )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\tconst categorySuggestions =\n\t\tcategoriesList?.reduce(\n\t\t\t( accumulator, category ) => ( {\n\t\t\t\t...accumulator,\n\t\t\t\t[ category.name ]: category,\n\t\t\t} ),\n\t\t\t{}\n\t\t) ?? {};\n\tconst selectCategories = ( tokens ) => {\n\t\tconst hasNoSuggestion = tokens.some(\n\t\t\t( token ) =>\n\t\t\t\ttypeof token === 'string' && ! categorySuggestions[ token ]\n\t\t);\n\t\tif ( hasNoSuggestion ) {\n\t\t\treturn;\n\t\t}\n\t\t// Categories that are already will be objects, while new additions will be strings (the name).\n\t\t// allCategories nomalizes the array so that they are all objects.\n\t\tconst allCategories = tokens.map( ( token ) => {\n\t\t\treturn typeof token === 'string'\n\t\t\t\t? categorySuggestions[ token ]\n\t\t\t\t: token;\n\t\t} );\n\t\t// We do nothing if the category is not selected\n\t\t// from suggestions.\n\t\tif ( allCategories.includes( null ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tsetAttributes( { categories: allCategories } );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Post content' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tdisplayPostContent: false,\n\t\t\t\t\t\tdisplayPostContentRadio: 'excerpt',\n\t\t\t\t\t\texcerptLength: DEFAULT_EXCERPT_LENGTH,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayPostContent }\n\t\t\t\t\tlabel={ __( 'Display post content' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayPostContent: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display post content' ) }\n\t\t\t\t\t\tchecked={ displayPostContent }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayPostContent: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t{ displayPostContent && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => displayPostContentRadio !== 'excerpt' }\n\t\t\t\t\t\tlabel={ __( 'Content length' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayPostContentRadio: 'excerpt',\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\tlabel={ __( 'Content length' ) }\n\t\t\t\t\t\t\tselected={ displayPostContentRadio }\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ label: __( 'Excerpt' ), value: 'excerpt' },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Full post' ),\n\t\t\t\t\t\t\t\t\tvalue: 'full_post',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdisplayPostContentRadio: value,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ displayPostContent &&\n\t\t\t\t\tdisplayPostContentRadio === 'excerpt' && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\texcerptLength !== DEFAULT_EXCERPT_LENGTH\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\texcerptLength: DEFAULT_EXCERPT_LENGTH,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\t\t\tvalue={ excerptLength }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { excerptLength: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmin={ MIN_EXCERPT_LENGTH }\n\t\t\t\t\t\t\t\tmax={ MAX_EXCERPT_LENGTH }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Post meta' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tdisplayAuthor: false,\n\t\t\t\t\t\tdisplayPostDate: false,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayAuthor }\n\t\t\t\t\tlabel={ __( 'Display author name' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayAuthor: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display author name' ) }\n\t\t\t\t\t\tchecked={ displayAuthor }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayAuthor: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayPostDate }\n\t\t\t\t\tlabel={ __( 'Display post date' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayPostDate: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display post date' ) }\n\t\t\t\t\t\tchecked={ displayPostDate }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayPostDate: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Featured image' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tdisplayFeaturedImage: false,\n\t\t\t\t\t\tfeaturedImageAlign: undefined,\n\t\t\t\t\t\tfeaturedImageSizeSlug: 'thumbnail',\n\t\t\t\t\t\tfeaturedImageSizeWidth: null,\n\t\t\t\t\t\tfeaturedImageSizeHeight: null,\n\t\t\t\t\t\taddLinkToFeaturedImage: false,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! displayFeaturedImage }\n\t\t\t\t\tlabel={ __( 'Display featured image' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { displayFeaturedImage: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display featured image' ) }\n\t\t\t\t\t\tchecked={ displayFeaturedImage }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { displayFeaturedImage: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t{ displayFeaturedImage && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\tfeaturedImageSizeSlug !== 'thumbnail' ||\n\t\t\t\t\t\t\t\tfeaturedImageSizeWidth !== null ||\n\t\t\t\t\t\t\t\tfeaturedImageSizeHeight !== null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tfeaturedImageSizeSlug: 'thumbnail',\n\t\t\t\t\t\t\t\t\tfeaturedImageSizeWidth: null,\n\t\t\t\t\t\t\t\t\tfeaturedImageSizeHeight: null,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ImageSizeControl\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tconst newAttrs = {};\n\t\t\t\t\t\t\t\t\tif ( value.hasOwnProperty( 'width' ) ) {\n\t\t\t\t\t\t\t\t\t\tnewAttrs.featuredImageSizeWidth =\n\t\t\t\t\t\t\t\t\t\t\tvalue.width;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( value.hasOwnProperty( 'height' ) ) {\n\t\t\t\t\t\t\t\t\t\tnewAttrs.featuredImageSizeHeight =\n\t\t\t\t\t\t\t\t\t\t\tvalue.height;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetAttributes( newAttrs );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tslug={ featuredImageSizeSlug }\n\t\t\t\t\t\t\t\twidth={ featuredImageSizeWidth }\n\t\t\t\t\t\t\t\theight={ featuredImageSizeHeight }\n\t\t\t\t\t\t\t\timageWidth={ defaultImageWidth }\n\t\t\t\t\t\t\t\timageHeight={ defaultImageHeight }\n\t\t\t\t\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t\t\t\t\t\timageSizeHelp={ __(\n\t\t\t\t\t\t\t\t\t'Select the size of the source image.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChangeImage={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tfeaturedImageSizeSlug: value,\n\t\t\t\t\t\t\t\t\t\tfeaturedImageSizeWidth: undefined,\n\t\t\t\t\t\t\t\t\t\tfeaturedImageSizeHeight: undefined,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! featuredImageAlign }\n\t\t\t\t\t\t\tlabel={ __( 'Image alignment' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tfeaturedImageAlign: undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t\tclassName=\"editor-latest-posts-image-alignment-control\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Image alignment' ) }\n\t\t\t\t\t\t\t\tvalue={ featuredImageAlign || 'none' }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tfeaturedImageAlign:\n\t\t\t\t\t\t\t\t\t\t\tvalue !== 'none'\n\t\t\t\t\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ imageAlignmentOptions.map(\n\t\t\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! addLinkToFeaturedImage }\n\t\t\t\t\t\t\tlabel={ __( 'Add link to featured image' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\taddLinkToFeaturedImage: false,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Add link to featured image' ) }\n\t\t\t\t\t\t\t\tchecked={ addLinkToFeaturedImage }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\taddLinkToFeaturedImage: value,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Sorting and filtering' ) }\n\t\t\t\tresetAll={ () =>\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\torder: 'desc',\n\t\t\t\t\t\torderBy: 'date',\n\t\t\t\t\t\tpostsToShow: 5,\n\t\t\t\t\t\tcategories: undefined,\n\t\t\t\t\t\tselectedAuthor: undefined,\n\t\t\t\t\t\tcolumns: 3,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\torder !== 'desc' ||\n\t\t\t\t\t\torderBy !== 'date' ||\n\t\t\t\t\t\tpostsToShow !== 5 ||\n\t\t\t\t\t\tcategories?.length > 0 ||\n\t\t\t\t\t\t!! selectedAuthor\n\t\t\t\t\t}\n\t\t\t\t\tlabel={ __( 'Sort and filter' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\torder: 'desc',\n\t\t\t\t\t\t\torderBy: 'date',\n\t\t\t\t\t\t\tpostsToShow: 5,\n\t\t\t\t\t\t\tcategories: undefined,\n\t\t\t\t\t\t\tselectedAuthor: undefined,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<QueryControls\n\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\tnumberOfItems={ postsToShow }\n\t\t\t\t\t\tonOrderChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { order: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonOrderByChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { orderBy: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonNumberOfItemsChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { postsToShow: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcategorySuggestions={ categorySuggestions }\n\t\t\t\t\t\tonCategoryChange={ selectCategories }\n\t\t\t\t\t\tselectedCategories={ categories }\n\t\t\t\t\t\tonAuthorChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tselectedAuthor:\n\t\t\t\t\t\t\t\t\t'' !== value ? Number( value ) : undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tauthorList={ authorList ?? [] }\n\t\t\t\t\t\tselectedAuthorId={ selectedAuthor }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t{ postLayout === 'grid' && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => columns !== 3 }\n\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tcolumns: 3,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\tvalue={ columns }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { columns: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\t! postCount\n\t\t\t\t\t\t\t\t\t? MAX_POSTS_COLUMNS\n\t\t\t\t\t\t\t\t\t: Math.min( MAX_POSTS_COLUMNS, postCount )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\t\t</>\n\t);\n}\n\nexport default function LatestPostsEdit( { attributes, setAttributes } ) {\n\tconst instanceId = useInstanceId( LatestPostsEdit );\n\n\tconst {\n\t\tpostsToShow,\n\t\torder,\n\t\torderBy,\n\t\tcategories,\n\t\tselectedAuthor,\n\t\tdisplayFeaturedImage,\n\t\tdisplayPostContentRadio,\n\t\tdisplayPostContent,\n\t\tdisplayPostDate,\n\t\tdisplayAuthor,\n\t\tpostLayout,\n\t\tcolumns,\n\t\texcerptLength,\n\t\tfeaturedImageAlign,\n\t\tfeaturedImageSizeSlug,\n\t\tfeaturedImageSizeWidth,\n\t\tfeaturedImageSizeHeight,\n\t\taddLinkToFeaturedImage,\n\t} = attributes;\n\tconst { latestPosts } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst catIds =\n\t\t\t\tcategories && categories.length > 0\n\t\t\t\t\t? categories.map( ( cat ) => cat.id )\n\t\t\t\t\t: [];\n\t\t\tconst latestPostsQuery = Object.fromEntries(\n\t\t\t\tObject.entries( {\n\t\t\t\t\tcategories: catIds,\n\t\t\t\t\tauthor: selectedAuthor,\n\t\t\t\t\torder,\n\t\t\t\t\torderby: orderBy,\n\t\t\t\t\tper_page: postsToShow,\n\t\t\t\t\t_embed: 'author,wp:featuredmedia',\n\t\t\t\t\tignore_sticky: true,\n\t\t\t\t} ).filter( ( [ , value ] ) => typeof value !== 'undefined' )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlatestPosts: getEntityRecords(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'post',\n\t\t\t\t\tlatestPostsQuery\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postsToShow, order, orderBy, categories, selectedAuthor ]\n\t);\n\n\t// If a user clicks to a link prevent redirection and show a warning.\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst hasPosts = !! latestPosts?.length;\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<Controls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tpostCount={ latestPosts?.length ?? 0 }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t'wp-block-latest-posts__list': true,\n\t\t\t'is-grid': postLayout === 'grid',\n\t\t\t'has-dates': displayPostDate,\n\t\t\t'has-author': displayAuthor,\n\t\t\t[ `columns-${ columns }` ]: postLayout === 'grid',\n\t\t} ),\n\t} );\n\n\tif ( ! hasPosts ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ inspectorControls }\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Latest Posts' ) }>\n\t\t\t\t\t{ ! Array.isArray( latestPosts ) ? (\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t__( 'No posts found.' )\n\t\t\t\t\t) }\n\t\t\t\t</Placeholder>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Removing posts from display should be instant.\n\tconst displayPosts =\n\t\tlatestPosts.length > postsToShow\n\t\t\t? latestPosts.slice( 0, postsToShow )\n\t\t\t: latestPosts;\n\n\tconst layoutControls = [\n\t\t{\n\t\t\ticon: list,\n\t\t\ttitle: _x( 'List view', 'Latest posts block display setting' ),\n\t\t\tonClick: () => setAttributes( { postLayout: 'list' } ),\n\t\t\tisActive: postLayout === 'list',\n\t\t},\n\t\t{\n\t\t\ticon: grid,\n\t\t\ttitle: _x( 'Grid view', 'Latest posts block display setting' ),\n\t\t\tonClick: () => setAttributes( { postLayout: 'grid' } ),\n\t\t\tisActive: postLayout === 'grid',\n\t\t},\n\t];\n\n\tconst dateFormat = getSettings().formats.date;\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup controls={ layoutControls } />\n\t\t\t</BlockControls>\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t{ displayPosts.map( ( post ) => {\n\t\t\t\t\tconst titleTrimmed = post.title.rendered.trim();\n\t\t\t\t\tlet excerpt = post.excerpt.rendered;\n\t\t\t\t\tconst currentAuthor = getCurrentAuthor( post );\n\n\t\t\t\t\tconst excerptElement = document.createElement( 'div' );\n\t\t\t\t\texcerptElement.innerHTML = excerpt;\n\n\t\t\t\t\texcerpt =\n\t\t\t\t\t\texcerptElement.textContent ||\n\t\t\t\t\t\texcerptElement.innerText ||\n\t\t\t\t\t\t'';\n\n\t\t\t\t\tconst { url: imageSourceUrl, alt: featuredImageAlt } =\n\t\t\t\t\t\tgetFeaturedImageDetails( post, featuredImageSizeSlug );\n\t\t\t\t\tconst imageClasses = clsx( {\n\t\t\t\t\t\t'wp-block-latest-posts__featured-image': true,\n\t\t\t\t\t\t[ `align${ featuredImageAlign }` ]:\n\t\t\t\t\t\t\t!! featuredImageAlign,\n\t\t\t\t\t} );\n\t\t\t\t\tconst renderFeaturedImage =\n\t\t\t\t\t\tdisplayFeaturedImage && imageSourceUrl;\n\t\t\t\t\tconst featuredImage = renderFeaturedImage && (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tsrc={ imageSourceUrl }\n\t\t\t\t\t\t\talt={ featuredImageAlt }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: featuredImageSizeWidth,\n\t\t\t\t\t\t\t\tmaxHeight: featuredImageSizeHeight,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\n\t\t\t\t\tconst needsReadMore =\n\t\t\t\t\t\texcerptLength < excerpt.trim().split( ' ' ).length &&\n\t\t\t\t\t\tpost.excerpt.raw === '';\n\n\t\t\t\t\tconst postExcerpt = needsReadMore ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ excerpt\n\t\t\t\t\t\t\t\t.trim()\n\t\t\t\t\t\t\t\t.split( ' ', excerptLength )\n\t\t\t\t\t\t\t\t.join( ' ' ) }\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: 1: Hidden accessibility text: Post title */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'\u2026 <a>Read more<span>: %1$s</span></a>'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\ttitleTrimmed || __( '(no title)' )\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__read-more\"\n\t\t\t\t\t\t\t\t\t\t\thref={ post.link }\n\t\t\t\t\t\t\t\t\t\t\trel=\"noopener\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\tshowRedirectionPreventedNotice\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t<span className=\"screen-reader-text\" />\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\texcerpt\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<li key={ post.id }>\n\t\t\t\t\t\t\t{ renderFeaturedImage && (\n\t\t\t\t\t\t\t\t<div className={ imageClasses }>\n\t\t\t\t\t\t\t\t\t{ addLinkToFeaturedImage ? (\n\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\thref={ post.link }\n\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\tshowRedirectionPreventedNotice\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ featuredImage }\n\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\tfeaturedImage\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__post-title\"\n\t\t\t\t\t\t\t\thref={ post.link }\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={\n\t\t\t\t\t\t\t\t\t!! titleTrimmed\n\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t__html: titleTrimmed,\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonClick={ showRedirectionPreventedNotice }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ! titleTrimmed ? __( '(no title)' ) : null }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t{ displayAuthor && currentAuthor && (\n\t\t\t\t\t\t\t\t<div className=\"wp-block-latest-posts__post-author\">\n\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: byline. %s: author. */\n\t\t\t\t\t\t\t\t\t\t__( 'by %s' ),\n\t\t\t\t\t\t\t\t\t\tcurrentAuthor.name\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPostDate && post.date_gmt && (\n\t\t\t\t\t\t\t\t<time\n\t\t\t\t\t\t\t\t\tdateTime={ format( 'c', post.date_gmt ) }\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__post-date\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ dateI18n( dateFormat, post.date_gmt ) }\n\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPostContent &&\n\t\t\t\t\t\t\t\tdisplayPostContentRadio === 'excerpt' && (\n\t\t\t\t\t\t\t\t\t<div className=\"wp-block-latest-posts__post-excerpt\">\n\t\t\t\t\t\t\t\t\t\t{ postExcerpt }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPostContent &&\n\t\t\t\t\t\t\t\tdisplayPostContentRadio === 'full_post' && (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-latest-posts__post-full-content\"\n\t\t\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t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A,YAEJ,SAAU;AAAA,YAER,WAAE,mBAAe,gBAAI,YAAa,IAAI;AAAA;AAAA,QACzC;AAAA,QACE,iBAAiB,iBAClB,4CAAC,SAAI,WAAU,sCACZ;AAAA;AAAA,cAED,gBAAI,OAAQ;AAAA,UACZ,cAAc;AAAA,QACf,GACD;AAAA,QAEC,mBAAmB,KAAK,YACzB;AAAA,UAAC;AAAA;AAAA,YACA,cAAW,oBAAQ,KAAK,KAAK,QAAS;AAAA,YACtC,WAAU;AAAA,YAER,oCAAU,YAAY,KAAK,QAAS;AAAA;AAAA,QACvC;AAAA,QAEC,sBACD,4BAA4B,aAC3B,4CAAC,SAAI,WAAU,uCACZ,uBACH;AAAA,QAEA,sBACD,4BAA4B,eAC3B;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,yBAA0B;AAAA,cACzB,QAAQ,KAAK,QAAQ,IAAI,KAAK;AAAA,YAC/B;AAAA;AAAA,QACD;AAAA,WA7DO,KAAK,EA+Df;AAAA,IAEF,CAAE,GACH;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["coreStore", "blockEditorStore", "ToolsPanel", "ToolsPanelItem", "ImageSizeControl", "ToggleGroupControl", "ToggleGroupControlOptionIcon", "noticeStore", "clsx"]
|
|
7
7
|
}
|
|
@@ -31,19 +31,13 @@ var import_block_editor = require("@wordpress/block-editor");
|
|
|
31
31
|
var import_blocks = require("@wordpress/blocks");
|
|
32
32
|
function useOnEnter(props) {
|
|
33
33
|
const { batch } = (0, import_data.useRegistry)();
|
|
34
|
-
const {
|
|
35
|
-
moveBlocksToPosition,
|
|
36
|
-
replaceInnerBlocks,
|
|
37
|
-
duplicateBlocks,
|
|
38
|
-
insertBlock
|
|
39
|
-
} = (0, import_data.useDispatch)(import_block_editor.store);
|
|
34
|
+
const { moveBlocksToPosition, replaceBlocks, selectionChange } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
40
35
|
const {
|
|
41
36
|
getBlockRootClientId,
|
|
42
37
|
getBlockIndex,
|
|
43
38
|
getBlockOrder,
|
|
44
39
|
getBlockName,
|
|
45
40
|
getBlock,
|
|
46
|
-
getNextBlockClientId,
|
|
47
41
|
canInsertBlockType
|
|
48
42
|
} = (0, import_data.useSelect)(import_block_editor.store);
|
|
49
43
|
const propsRef = (0, import_element.useRef)(props);
|
|
@@ -97,23 +91,18 @@ function useOnEnter(props) {
|
|
|
97
91
|
}
|
|
98
92
|
event.preventDefault();
|
|
99
93
|
const wrapperBlock = getBlock(wrapperClientId);
|
|
94
|
+
const head = (0, import_blocks.cloneBlock)({
|
|
95
|
+
...wrapperBlock,
|
|
96
|
+
innerBlocks: wrapperBlock.innerBlocks.slice(0, position)
|
|
97
|
+
});
|
|
98
|
+
const middle = (0, import_blocks.createBlock)(defaultBlockName);
|
|
99
|
+
const tail = (0, import_blocks.cloneBlock)({
|
|
100
|
+
...wrapperBlock,
|
|
101
|
+
innerBlocks: wrapperBlock.innerBlocks.slice(position + 1)
|
|
102
|
+
});
|
|
100
103
|
batch(() => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
replaceInnerBlocks(
|
|
104
|
-
wrapperClientId,
|
|
105
|
-
wrapperBlock.innerBlocks.slice(0, position)
|
|
106
|
-
);
|
|
107
|
-
replaceInnerBlocks(
|
|
108
|
-
getNextBlockClientId(wrapperClientId),
|
|
109
|
-
wrapperBlock.innerBlocks.slice(position + 1)
|
|
110
|
-
);
|
|
111
|
-
insertBlock(
|
|
112
|
-
(0, import_blocks.createBlock)(defaultBlockName),
|
|
113
|
-
blockIndex + 1,
|
|
114
|
-
grandparentClientId,
|
|
115
|
-
true
|
|
116
|
-
);
|
|
104
|
+
replaceBlocks(wrapperClientId, [head, middle, tail]);
|
|
105
|
+
selectionChange(middle.clientId);
|
|
117
106
|
});
|
|
118
107
|
}
|
|
119
108
|
element.addEventListener("keydown", onKeyDown);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/use-enter.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\thasBlockSupport,\n\tcreateBlock,\n\tgetDefaultBlockName,\n} from '@wordpress/blocks';\n\nexport function useOnEnter( props ) {\n\tconst { batch } = useRegistry();\n\tconst {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAuB;AACvB,qBAA6B;AAC7B,sBAAsB;AACtB,kBAAoD;AACpD,0BAA0C;AAC1C,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\thasBlockSupport,\n\tcreateBlock,\n\tcloneBlock,\n\tgetDefaultBlockName,\n} from '@wordpress/blocks';\n\nexport function useOnEnter( props ) {\n\tconst { batch } = useRegistry();\n\tconst { moveBlocksToPosition, replaceBlocks, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockOrder,\n\t\tgetBlockName,\n\t\tgetBlock,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { content, clientId } = propsRef.current;\n\n\t\t\t// The paragraph should be empty.\n\t\t\tif ( content.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst wrapperClientId = getBlockRootClientId( clientId );\n\n\t\t\tif (\n\t\t\t\t! hasBlockSupport(\n\t\t\t\t\tgetBlockName( wrapperClientId ),\n\t\t\t\t\t'__experimentalOnEnter',\n\t\t\t\t\tfalse\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst order = getBlockOrder( wrapperClientId );\n\t\t\tconst position = order.indexOf( clientId );\n\n\t\t\t// If it is the last block, exit.\n\t\t\tif ( position === order.length - 1 ) {\n\t\t\t\tlet newWrapperClientId = wrapperClientId;\n\n\t\t\t\twhile (\n\t\t\t\t\t! canInsertBlockType(\n\t\t\t\t\t\tgetBlockName( clientId ),\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tnewWrapperClientId =\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId );\n\t\t\t\t}\n\n\t\t\t\tif ( typeof newWrapperClientId === 'string' ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ clientId ],\n\t\t\t\t\t\twrapperClientId,\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId ),\n\t\t\t\t\t\tgetBlockIndex( newWrapperClientId ) + 1\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst defaultBlockName = getDefaultBlockName();\n\t\t\tconst wrapperBlockName = getBlockName( wrapperClientId );\n\t\t\tconst grandparentClientId = getBlockRootClientId( wrapperClientId );\n\n\t\t\tif (\n\t\t\t\t! canInsertBlockType( defaultBlockName, grandparentClientId ) ||\n\t\t\t\t! canInsertBlockType( wrapperBlockName, grandparentClientId )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// If it is in the middle, split the block in two.\n\t\t\tconst wrapperBlock = getBlock( wrapperClientId );\n\t\t\tconst head = cloneBlock( {\n\t\t\t\t...wrapperBlock,\n\t\t\t\tinnerBlocks: wrapperBlock.innerBlocks.slice( 0, position ),\n\t\t\t} );\n\t\t\tconst middle = createBlock( defaultBlockName );\n\t\t\tconst tail = cloneBlock( {\n\t\t\t\t...wrapperBlock,\n\t\t\t\tinnerBlocks: wrapperBlock.innerBlocks.slice( position + 1 ),\n\t\t\t} );\n\n\t\t\tbatch( () => {\n\t\t\t\treplaceBlocks( wrapperClientId, [ head, middle, tail ] );\n\t\t\t\t// The selected paragraph is a descendant of the replaced\n\t\t\t\t// wrapper, so `replaceBlocks` leaves the selection stale.\n\t\t\t\t// Move it to the new default block explicitly.\n\t\t\t\tselectionChange( middle.clientId );\n\t\t\t} );\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAuB;AACvB,qBAA6B;AAC7B,sBAAsB;AACtB,kBAAoD;AACpD,0BAA0C;AAC1C,oBAKO;AAEA,SAAS,WAAY,OAAQ;AACnC,QAAM,EAAE,MAAM,QAAI,yBAAY;AAC9B,QAAM,EAAE,sBAAsB,eAAe,gBAAgB,QAC5D,yBAAa,oBAAAA,KAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,oBAAAA,KAAiB;AAChC,QAAM,eAAW,uBAAQ,KAAM;AAC/B,WAAS,UAAU;AACnB,aAAO,6BAAc,CAAE,YAAa;AACnC,aAAS,UAAW,OAAQ;AAC3B,UAAK,MAAM,kBAAmB;AAC7B;AAAA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EF,YAAO,MAAM;AACZ,sBAAe,iBAAiB,CAAE,MAAM,QAAQ,IAAK,CAAE;AAIvD,wBAAiB,OAAO,QAAS;AAAA,MAClC,CAAE;AAAA,IACH;AAEA,YAAQ,iBAAkB,WAAW,SAAU;AAC/C,WAAO,MAAM;AACZ,cAAQ,oBAAqB,WAAW,SAAU;AAAA,IACnD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -241,11 +241,8 @@ function PostFeaturedImageEdit({
|
|
|
241
241
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
242
242
|
import_components.ToggleControl,
|
|
243
243
|
{
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
(0, import_i18n.__)("Link to %s"),
|
|
247
|
-
postType.labels.singular_name
|
|
248
|
-
) : (0, import_i18n.__)("Link to post"),
|
|
244
|
+
__nextHasNoMarginBottom: true,
|
|
245
|
+
label: (0, import_i18n.__)("Make image a link"),
|
|
249
246
|
onChange: () => setAttributes({ isLink: !isLink }),
|
|
250
247
|
checked: isLink
|
|
251
248
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/post-featured-image/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tToggleControl,\n\tPlaceholder,\n\tButton,\n\tSpinner,\n\tTextControl,\n\tExternalLink,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tuseBlockEditingMode,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseEffect,\n\tuseState,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\nimport OverlayControls from './overlay-controls';\nimport Overlay from './overlay';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport { unlock } from '../lock-unlock';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst { ResolutionTool } = unlock( blockEditorPrivateApis );\nconst DEFAULT_MEDIA_SIZE_SLUG = 'full';\n\nfunction FeaturedImageResolutionTool( { image, value, onChange } ) {\n\tconst { imageSizes } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\timageSizes: getSettings().imageSizes,\n\t\t};\n\t}, [] );\n\n\tif ( ! imageSizes?.length ) {\n\t\treturn null;\n\t}\n\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\n\treturn (\n\t\t<ResolutionTool\n\t\t\tvalue={ value }\n\t\t\tdefaultValue={ DEFAULT_MEDIA_SIZE_SLUG }\n\t\t\toptions={ imageSizeOptions }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\nexport default function PostFeaturedImageEdit( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType: postTypeSlug, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst {\n\t\tisLink,\n\t\taspectRatio,\n\t\theight,\n\t\twidth,\n\t\tscale,\n\t\tsizeSlug,\n\t\trel,\n\t\tlinkTarget,\n\t\tuseFirstImageFromPost,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState();\n\n\tconst [ storedFeaturedImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\t// Fallback to post content if no featured image is set.\n\t// This is needed for the \"Use first image from post\" option.\n\tconst [ postContent ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'content',\n\t\tpostId\n\t);\n\n\tconst featuredImage = useMemo( () => {\n\t\tif ( storedFeaturedImage ) {\n\t\t\treturn storedFeaturedImage;\n\t\t}\n\n\t\tif ( ! useFirstImageFromPost ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst imageOpener =\n\t\t\t/<!--\\s+wp:(?:core\\/)?image\\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\\s+\\/?-->).)*)?}\\s+)?-->/.exec(\n\t\t\t\tpostContent\n\t\t\t);\n\t\tconst imageId =\n\t\t\timageOpener?.groups?.attrs &&\n\t\t\tJSON.parse( imageOpener.groups.attrs )?.id;\n\t\treturn imageId;\n\t}, [ storedFeaturedImage, useFirstImageFromPost, postContent ] );\n\n\tconst { media, postType, postPermalink } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getPostType, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage &&\n\t\t\t\t\tgetEntityRecord( 'postType', 'attachment', featuredImage, {\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t} ),\n\t\t\t\tpostType: postTypeSlug && getPostType( postTypeSlug ),\n\t\t\t\tpostPermalink: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\tpostId\n\t\t\t\t)?.link,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, postTypeSlug, postId ]\n\t);\n\n\tconst mediaUrl =\n\t\tmedia?.media_details?.sizes?.[ sizeSlug ]?.source_url ||\n\t\tmedia?.source_url;\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height, aspectRatio },\n\t\tclassName: clsx( {\n\t\t\t'is-transient': temporaryURL,\n\t\t} ),\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-media-placeholder',\n\t\t\t\t\tborderProps.className\n\t\t\t\t) }\n\t\t\t\twithIllustration\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: !! aspectRatio && '100%',\n\t\t\t\t\twidth: !! aspectRatio && '100%',\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{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\n\t\tif ( value?.url && isBlobURL( value.url ) ) {\n\t\t\tsetTemporaryURL( value.url );\n\t\t}\n\t};\n\n\t// On reset image\n\tconst onResetImage = () => {\n\t\tsetAttributes( {\n\t\t\tisLink: false,\n\t\t\tlinkTarget: '_self',\n\t\t\trel: '',\n\t\t\tsizeSlug: undefined,\n\t\t} );\n\t\tsetFeaturedImage( 0 );\n\t};\n\n\t// Reset temporary url when media is available.\n\tuseEffect( () => {\n\t\tif ( mediaUrl && temporaryURL ) {\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}, [ mediaUrl, temporaryURL ] );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetTemporaryURL();\n\t};\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst controls = blockEditingMode === 'default' && (\n\t\t<>\n\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t<OverlayControls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"dimensions\">\n\t\t\t\t<DimensionControls\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tmedia={ media }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ ( featuredImage || isDescendentOfQueryLoop || ! postId ) && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tisLink: false,\n\t\t\t\t\t\t\t\tlinkTarget: '_self',\n\t\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t\t\tsizeSlug: DEFAULT_MEDIA_SIZE_SLUG,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => !! isLink }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tisLink: false,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { isLink: ! isLink } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => '_self' !== linkTarget }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tlinkTarget: value\n\t\t\t\t\t\t\t\t\t\t\t\t? '_blank'\n\t\t\t\t\t\t\t\t\t\t\t\t: '_self',\n\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => !! rel }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\t\t\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://developer.mozilla.org/docs/Web/HTML/Attributes/rel\" />\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ !! media && (\n\t\t\t\t\t\t\t<FeaturedImageResolutionTool\n\t\t\t\t\t\t\t\timage={ media }\n\t\t\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\t\t\tonChange={ ( nextSizeSlug ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { sizeSlug: nextSizeSlug } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n\n\tlet image;\n\n\t/**\n\t * A Post Featured Image block should not have image replacement\n\t * or upload options in the following cases:\n\t * - Is placed in a Query Loop. This is a conscious decision to\n\t * prevent content editing of different posts in Query Loop, and\n\t * this could change in the future.\n\t * - Is in a context where it does not have a postId (for example\n\t * in a template or template part).\n\t */\n\tif ( ! featuredImage && ( isDescendentOfQueryLoop || ! postId ) ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t\t<a href={ postPermalink } target={ linkTarget }>\n\t\t\t\t\t\t\t{ placeholder() }\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tplaceholder()\n\t\t\t\t\t) }\n\t\t\t\t\t<Overlay\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\tconst imageStyles = {\n\t\t...borderProps.style,\n\t\t...shadowProps.style,\n\t\theight: aspectRatio ? '100%' : height,\n\t\twidth: !! aspectRatio && '100%',\n\t\tobjectFit: !! ( height || aspectRatio ) && scale,\n\t};\n\n\t/**\n\t * When the post featured image block is placed in a context where:\n\t * - It has a postId (for example in a single post)\n\t * - It is not inside a query loop\n\t * - It has no image assigned yet\n\t * Then display the placeholder with the image upload option.\n\t */\n\tif ( ! featuredImage && ! temporaryURL ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage =\n\t\t\t! media && ! temporaryURL ? (\n\t\t\t\tplaceholder()\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName={ borderProps.className }\n\t\t\t\t\t\tsrc={ temporaryURL || mediaUrl }\n\t\t\t\t\t\talt={\n\t\t\t\t\t\t\tmedia && media?.alt_text\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ imageStyles }\n\t\t\t\t\t/>\n\t\t\t\t\t{ temporaryURL && <Spinner /> }\n\t\t\t\t</>\n\t\t\t);\n\t}\n\n\t/**\n\t * When the post featured image block:\n\t * - Has an image assigned\n\t * - Is not inside a query loop\n\t * Then display the image and the image replacement option.\n\t */\n\treturn (\n\t\t<>\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\tonReset={ onResetImage }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /* If the featured image is linked, wrap in an <a /> tag to trigger any inherited link element styles */ }\n\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t<a href={ postPermalink } target={ linkTarget }>\n\t\t\t\t\t\t{ image }\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\timage\n\t\t\t\t) }\n\t\t\t\t<Overlay\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAK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ACA;AAAA,QACA;AAAA;AAAA,IACD,GACD;AAAA,KACI,iBAAiB,2BAA2B,CAAE,WACjD,4CAAC,yCACA;AAAA,MAAC,kBAAAC;AAAA,MAAA;AAAA,QACA,WAAQ,gBAAI,UAAW;AAAA,QACvB,UAAW,MAAM;AAChB,wBAAe;AAAA,YACd,QAAQ;AAAA,YACR,YAAY;AAAA,YACZ,KAAK;AAAA,YACL,UAAU;AAAA,UACX,CAAE;AAAA,QACH;AAAA,QACA;AAAA,QAEA;AAAA;AAAA,YAAC,kBAAAC;AAAA,YAAA;AAAA,cACA,OACC,UAAU,OAAO,oBACd;AAAA;AAAA,oBAEA,gBAAI,YAAa;AAAA,gBACjB,SAAS,OAAO;AAAA,cAChB,QACA,gBAAI,cAAe;AAAA,cAEvB,kBAAgB;AAAA,cAChB,UAAW,MAAM,CAAC,CAAE;AAAA,cACpB,YAAa,MACZ,cAAe;AAAA,gBACd,QAAQ;AAAA,cACT,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tToggleControl,\n\tPlaceholder,\n\tButton,\n\tSpinner,\n\tTextControl,\n\tExternalLink,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tuseBlockEditingMode,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseEffect,\n\tuseState,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\nimport OverlayControls from './overlay-controls';\nimport Overlay from './overlay';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport { unlock } from '../lock-unlock';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst { ResolutionTool } = unlock( blockEditorPrivateApis );\nconst DEFAULT_MEDIA_SIZE_SLUG = 'full';\n\nfunction FeaturedImageResolutionTool( { image, value, onChange } ) {\n\tconst { imageSizes } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\timageSizes: getSettings().imageSizes,\n\t\t};\n\t}, [] );\n\n\tif ( ! imageSizes?.length ) {\n\t\treturn null;\n\t}\n\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\n\treturn (\n\t\t<ResolutionTool\n\t\t\tvalue={ value }\n\t\t\tdefaultValue={ DEFAULT_MEDIA_SIZE_SLUG }\n\t\t\toptions={ imageSizeOptions }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\nexport default function PostFeaturedImageEdit( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType: postTypeSlug, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst {\n\t\tisLink,\n\t\taspectRatio,\n\t\theight,\n\t\twidth,\n\t\tscale,\n\t\tsizeSlug,\n\t\trel,\n\t\tlinkTarget,\n\t\tuseFirstImageFromPost,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState();\n\n\tconst [ storedFeaturedImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\t// Fallback to post content if no featured image is set.\n\t// This is needed for the \"Use first image from post\" option.\n\tconst [ postContent ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'content',\n\t\tpostId\n\t);\n\n\tconst featuredImage = useMemo( () => {\n\t\tif ( storedFeaturedImage ) {\n\t\t\treturn storedFeaturedImage;\n\t\t}\n\n\t\tif ( ! useFirstImageFromPost ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst imageOpener =\n\t\t\t/<!--\\s+wp:(?:core\\/)?image\\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\\s+\\/?-->).)*)?}\\s+)?-->/.exec(\n\t\t\t\tpostContent\n\t\t\t);\n\t\tconst imageId =\n\t\t\timageOpener?.groups?.attrs &&\n\t\t\tJSON.parse( imageOpener.groups.attrs )?.id;\n\t\treturn imageId;\n\t}, [ storedFeaturedImage, useFirstImageFromPost, postContent ] );\n\n\tconst { media, postType, postPermalink } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getPostType, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage &&\n\t\t\t\t\tgetEntityRecord( 'postType', 'attachment', featuredImage, {\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t} ),\n\t\t\t\tpostType: postTypeSlug && getPostType( postTypeSlug ),\n\t\t\t\tpostPermalink: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\tpostId\n\t\t\t\t)?.link,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, postTypeSlug, postId ]\n\t);\n\n\tconst mediaUrl =\n\t\tmedia?.media_details?.sizes?.[ sizeSlug ]?.source_url ||\n\t\tmedia?.source_url;\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height, aspectRatio },\n\t\tclassName: clsx( {\n\t\t\t'is-transient': temporaryURL,\n\t\t} ),\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-media-placeholder',\n\t\t\t\t\tborderProps.className\n\t\t\t\t) }\n\t\t\t\twithIllustration\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: !! aspectRatio && '100%',\n\t\t\t\t\twidth: !! aspectRatio && '100%',\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{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\n\t\tif ( value?.url && isBlobURL( value.url ) ) {\n\t\t\tsetTemporaryURL( value.url );\n\t\t}\n\t};\n\n\t// On reset image\n\tconst onResetImage = () => {\n\t\tsetAttributes( {\n\t\t\tisLink: false,\n\t\t\tlinkTarget: '_self',\n\t\t\trel: '',\n\t\t\tsizeSlug: undefined,\n\t\t} );\n\t\tsetFeaturedImage( 0 );\n\t};\n\n\t// Reset temporary url when media is available.\n\tuseEffect( () => {\n\t\tif ( mediaUrl && temporaryURL ) {\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}, [ mediaUrl, temporaryURL ] );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetTemporaryURL();\n\t};\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst controls = blockEditingMode === 'default' && (\n\t\t<>\n\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t<OverlayControls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"dimensions\">\n\t\t\t\t<DimensionControls\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tmedia={ media }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t{ ( featuredImage || isDescendentOfQueryLoop || ! postId ) && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tisLink: false,\n\t\t\t\t\t\t\t\tlinkTarget: '_self',\n\t\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t\t\tsizeSlug: DEFAULT_MEDIA_SIZE_SLUG,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => !! isLink }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tisLink: false,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Make image a link' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { isLink: ! isLink } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => '_self' !== linkTarget }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tlinkTarget: value\n\t\t\t\t\t\t\t\t\t\t\t\t? '_blank'\n\t\t\t\t\t\t\t\t\t\t\t\t: '_self',\n\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => !! rel }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\t\t\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://developer.mozilla.org/docs/Web/HTML/Attributes/rel\" />\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ !! media && (\n\t\t\t\t\t\t\t<FeaturedImageResolutionTool\n\t\t\t\t\t\t\t\timage={ media }\n\t\t\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\t\t\tonChange={ ( nextSizeSlug ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { sizeSlug: nextSizeSlug } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n\n\tlet image;\n\n\t/**\n\t * A Post Featured Image block should not have image replacement\n\t * or upload options in the following cases:\n\t * - Is placed in a Query Loop. This is a conscious decision to\n\t * prevent content editing of different posts in Query Loop, and\n\t * this could change in the future.\n\t * - Is in a context where it does not have a postId (for example\n\t * in a template or template part).\n\t */\n\tif ( ! featuredImage && ( isDescendentOfQueryLoop || ! postId ) ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t\t<a href={ postPermalink } target={ linkTarget }>\n\t\t\t\t\t\t\t{ placeholder() }\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tplaceholder()\n\t\t\t\t\t) }\n\t\t\t\t\t<Overlay\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\tconst imageStyles = {\n\t\t...borderProps.style,\n\t\t...shadowProps.style,\n\t\theight: aspectRatio ? '100%' : height,\n\t\twidth: !! aspectRatio && '100%',\n\t\tobjectFit: !! ( height || aspectRatio ) && scale,\n\t};\n\n\t/**\n\t * When the post featured image block is placed in a context where:\n\t * - It has a postId (for example in a single post)\n\t * - It is not inside a query loop\n\t * - It has no image assigned yet\n\t * Then display the placeholder with the image upload option.\n\t */\n\tif ( ! featuredImage && ! temporaryURL ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage =\n\t\t\t! media && ! temporaryURL ? (\n\t\t\t\tplaceholder()\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName={ borderProps.className }\n\t\t\t\t\t\tsrc={ temporaryURL || mediaUrl }\n\t\t\t\t\t\talt={\n\t\t\t\t\t\t\tmedia && media?.alt_text\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ imageStyles }\n\t\t\t\t\t/>\n\t\t\t\t\t{ temporaryURL && <Spinner /> }\n\t\t\t\t</>\n\t\t\t);\n\t}\n\n\t/**\n\t * When the post featured image block:\n\t * - Has an image assigned\n\t * - Is not inside a query loop\n\t * Then display the image and the image replacement option.\n\t */\n\treturn (\n\t\t<>\n\t\t\t{ ! temporaryURL && controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\tonReset={ onResetImage }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /* If the featured image is linked, wrap in an <a /> tag to trigger any inherited link element styles */ }\n\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t<a href={ postPermalink } target={ linkTarget }>\n\t\t\t\t\t\t{ image }\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\timage\n\t\t\t\t) }\n\t\t\t\t<Overlay\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA0B;AAC1B,uBAAkD;AAClD,kBAAuC;AACvC,wBASO;AACP,0BAWO;AACP,qBAKO;AACP,kBAA4B;AAC5B,mBAAuB;AACvB,qBAAsC;AAKtC,gCAA8B;AAC9B,8BAA4B;AAC5B,qBAAoB;AACpB,mBAA+C;AAC/C,yBAAuB;AAyBrB;AAvBF,IAAM,sBAAsB,CAAE,OAAQ;AACtC,IAAM,EAAE,eAAe,QAAI,2BAAQ,oBAAAA,WAAuB;AAC1D,IAAM,0BAA0B;AAEhC,SAAS,4BAA6B,EAAE,OAAO,OAAO,SAAS,GAAI;AAClE,QAAM,EAAE,WAAW,QAAI,uBAAW,CAAE,WAAY;AAC/C,UAA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A,UACD;AAAA,QAEF;AAAA;AAAA,IACD;AAAA,EAEF,OAAO;AAEN,YACC,CAAE,SAAS,CAAE,eACZ,YAAY,IAEZ,4EACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,WAAY,YAAY;AAAA,UACxB,KAAM,gBAAgB;AAAA,UACtB,KACC,SAAS,OAAO,eACb;AAAA;AAAA,gBAEA,gBAAI,oBAAqB;AAAA,YACzB,MAAM;AAAA,UACN,QACA,gBAAI,gBAAiB;AAAA,UAEzB,OAAQ;AAAA;AAAA,MACT;AAAA,MACE,gBAAgB,4CAAC,6BAAQ;AAAA,OAC5B;AAAA,EAEH;AAQA,SACC,4EACG;AAAA,KAAE,gBAAgB;AAAA,IAClB,CAAC,CAAE,SAAS,CAAE,2BACf,4CAAC,qCAAc,OAAM,SACpB;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,QACV,UAAW;AAAA,QACX,cAAe;AAAA,QACf,QAAO;AAAA,QACP,UAAW;AAAA,QACX,SAAU;AAAA,QACV,SAAU;AAAA;AAAA,IACX,GACD;AAAA,IAED,6CAAC,YAAS,GAAG,YAEV;AAAA,OAAC,CAAE,SACJ,4CAAC,OAAE,MAAO,eAAgB,QAAS,YAChC,iBACH,IAEA;AAAA,MAED;AAAA,QAAC,eAAAA;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,OACD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["blockEditorPrivateApis", "blockEditorStore", "coreStore", "clsx", "useBorderProps", "getShadowClassesAndStyles", "noticesStore", "OverlayControls", "DimensionControls", "ToolsPanel", "ToolsPanelItem", "Overlay"]
|
|
7
7
|
}
|
|
@@ -130,7 +130,11 @@ function PostTemplateEdit({
|
|
|
130
130
|
attributes: { layout },
|
|
131
131
|
__unstableLayoutClassNames
|
|
132
132
|
}) {
|
|
133
|
-
const {
|
|
133
|
+
const {
|
|
134
|
+
type: layoutType,
|
|
135
|
+
columnCount = 3,
|
|
136
|
+
minimumColumnWidth
|
|
137
|
+
} = layout || {};
|
|
134
138
|
const [activeBlockContextId, setActiveBlockContextId] = (0, import_element.useState)();
|
|
135
139
|
const { posts, blocks } = (0, import_data.useSelect)(
|
|
136
140
|
(select) => {
|
|
@@ -264,8 +268,10 @@ function PostTemplateEdit({
|
|
|
264
268
|
);
|
|
265
269
|
const blockProps = (0, import_block_editor.useBlockProps)({
|
|
266
270
|
className: (0, import_clsx.default)(__unstableLayoutClassNames, {
|
|
267
|
-
[`columns-${columnCount}`]: layoutType === "grid" && columnCount
|
|
271
|
+
[`columns-${columnCount}`]: layoutType === "grid" && columnCount,
|
|
268
272
|
// Ensure column count is flagged via classname for backwards compatibility.
|
|
273
|
+
"has-native-responsive-grid": layoutType === "grid" && columnCount && minimumColumnWidth
|
|
274
|
+
// Flag native responsive grid when minimum column width is provided.
|
|
269
275
|
})
|
|
270
276
|
});
|
|
271
277
|
if (!posts) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/post-template/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner, ToolbarGroup } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { list, grid } from '@wordpress/icons';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[\n\t\t'core/post-date',\n\t\t{\n\t\t\tmetadata: {\n\t\t\t\tbindings: {\n\t\t\t\t\tdatetime: {\n\t\t\t\t\t\tsource: 'core/post-data',\n\t\t\t\t\t\targs: { field: 'date' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks( { classList } ) {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: clsx( 'wp-block-post', classList ) },\n\t\t{ template: TEMPLATE, __unstableDisableLayoutClassNames: true }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tclassList,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: clsx( 'wp-block-post', classList ),\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tsetAttributes,\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset = 0,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpages,\n\t\t\tformat,\n\t\t\t// We gather extra query args to pass to the REST API call.\n\t\t\t// This way extenders of Query Loop can add their own query args,\n\t\t\t// and have accurate previews in the editor.\n\t\t\t// Noting though that these args should either be supported by the\n\t\t\t// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.\n\t\t\t...restQueryArgs\n\t\t} = {},\n\t\ttemplateSlug,\n\t\tpreviewPostType,\n\t},\n\tattributes: { layout },\n\t__unstableLayoutClassNames,\n} ) {\n\tconst { type: layoutType, columnCount = 3 } = layout || {};\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst templateCategory =\n\t\t\t\tinherit &&\n\t\t\t\ttemplateSlug?.startsWith( 'category-' ) &&\n\t\t\t\tgetEntityRecords( 'taxonomy', 'category', {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\t_fields: [ 'id' ],\n\t\t\t\t\tslug: templateSlug.replace( 'category-', '' ),\n\t\t\t\t} );\n\t\t\tconst templateTag =\n\t\t\t\tinherit &&\n\t\t\t\ttemplateSlug?.startsWith( 'tag-' ) &&\n\t\t\t\tgetEntityRecords( 'taxonomy', 'post_tag', {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\t_fields: [ 'id' ],\n\t\t\t\t\tslug: templateSlug.replace( 'tag-', '' ),\n\t\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: offset || 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\t// There is no need to build the taxQuery if we inherit.\n\t\t\tif ( taxQuery && ! inherit ) {\n\t\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\t\ttype: postType,\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t} );\n\t\t\t\t// Build REST API parameters from taxonomy terms, e.g.\n\t\t\t\t// `category`, `tags_exclude`.\n\t\t\t\tconst buildTaxQuery = ( terms, suffix = '' ) => {\n\t\t\t\t\treturn Object.entries( terms || {} ).reduce(\n\t\t\t\t\t\t( accumulator, [ taxonomySlug, termIds ] ) => {\n\t\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( taxonomy?.rest_base && termIds?.length ) {\n\t\t\t\t\t\t\t\taccumulator[ taxonomy.rest_base + suffix ] =\n\t\t\t\t\t\t\t\t\ttermIds;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst builtTaxQuery = buildTaxQuery( taxQuery.include );\n\t\t\t\tif ( taxQuery.exclude ) {\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\tbuiltTaxQuery,\n\t\t\t\t\t\tbuildTaxQuery( taxQuery.exclude, '_exclude' )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\tif ( format?.length ) {\n\t\t\t\tquery.format = format;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Handle cases where sticky is set to `exclude` or `only`.\n\t\t\t * Which works as a `post__in/post__not_in` query for sticky posts.\n\t\t\t */\n\t\t\tif ( [ 'exclude', 'only' ].includes( sticky ) ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\n\t\t\t// Empty string represents the default behavior of including sticky posts.\n\t\t\tif ( [ '', 'ignore' ].includes( sticky ) ) {\n\t\t\t\t// Remove any leftover sticky query parameter.\n\t\t\t\tdelete query.sticky;\n\t\t\t\tquery.ignore_sticky = sticky === 'ignore';\n\t\t\t}\n\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tlet currentPostType = postType;\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tcurrentPostType = query.postType;\n\t\t\t\t} else if ( templateCategory ) {\n\t\t\t\t\tquery.categories = templateCategory[ 0 ]?.id;\n\t\t\t\t} else if ( templateTag ) {\n\t\t\t\t\tquery.tags = templateTag[ 0 ]?.id;\n\t\t\t\t} else if (\n\t\t\t\t\ttemplateSlug?.startsWith( 'taxonomy-post_format' )\n\t\t\t\t) {\n\t\t\t\t\t// Get the post format slug from the template slug by removing the prefix.\n\t\t\t\t\tquery.format = templateSlug.replace(\n\t\t\t\t\t\t'taxonomy-post_format-post-format-',\n\t\t\t\t\t\t''\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || currentPostType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, {\n\t\t\t\t\t...query,\n\t\t\t\t\t...restQueryArgs,\n\t\t\t\t} ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tformat,\n\t\t\trestQueryArgs,\n\t\t\tpreviewPostType,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t\tclassList: post.class_list ?? '',\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( __unstableLayoutClassNames, {\n\t\t\t[ `columns-${ columnCount }` ]:\n\t\t\t\tlayoutType === 'grid' && columnCount, // Ensure column count is flagged via classname for backwards compatibility.\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\tconst setDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tlayout: { ...layout, ...newDisplayLayout },\n\t\t} );\n\n\tconst displayLayoutControls = [\n\t\t{\n\t\t\ticon: list,\n\t\t\ttitle: _x( 'List view', 'Post template block display setting' ),\n\t\t\tonClick: () => setDisplayLayout( { type: 'default' } ),\n\t\t\tisActive: layoutType === 'default' || layoutType === 'constrained',\n\t\t},\n\t\t{\n\t\t\ticon: grid,\n\t\t\ttitle: _x( 'Grid view', 'Post template block display setting' ),\n\t\t\tonClick: () =>\n\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\ttype: 'grid',\n\t\t\t\t\tcolumnCount,\n\t\t\t\t} ),\n\t\t\tisActive: layoutType === 'grid',\n\t\t},\n\t];\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup controls={ displayLayoutControls } />\n\t\t\t</BlockControls>\n\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t{ blockContexts &&\n\t\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t\t<PostTemplateInnerBlocks\n\t\t\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\n\t\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\t\tsetActiveBlockContextId={\n\t\t\t\t\t\t\t\t\tsetActiveBlockContextId\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\t\tblockContext.postId ===\n\t\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAwC;AACxC,kBAA0B;AAC1B,kBAAuB;AACvB,0BAOO;AACP,wBAAsC;AACtC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ACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMA,GAAG;AAAA,IACJ,IAAI,CAAC;AAAA,IACL;AAAA,IACA;AAAA,EACD;AAAA,EACA,YAAY,EAAE,OAAO;AAAA,EACrB;AACD,GAAI;AACH,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner, ToolbarGroup } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { list, grid } from '@wordpress/icons';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[\n\t\t'core/post-date',\n\t\t{\n\t\t\tmetadata: {\n\t\t\t\tbindings: {\n\t\t\t\t\tdatetime: {\n\t\t\t\t\t\tsource: 'core/post-data',\n\t\t\t\t\t\targs: { field: 'date' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks( { classList } ) {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: clsx( 'wp-block-post', classList ) },\n\t\t{ template: TEMPLATE, __unstableDisableLayoutClassNames: true }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tclassList,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: clsx( 'wp-block-post', classList ),\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tsetAttributes,\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset = 0,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpages,\n\t\t\tformat,\n\t\t\t// We gather extra query args to pass to the REST API call.\n\t\t\t// This way extenders of Query Loop can add their own query args,\n\t\t\t// and have accurate previews in the editor.\n\t\t\t// Noting though that these args should either be supported by the\n\t\t\t// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.\n\t\t\t...restQueryArgs\n\t\t} = {},\n\t\ttemplateSlug,\n\t\tpreviewPostType,\n\t},\n\tattributes: { layout },\n\t__unstableLayoutClassNames,\n} ) {\n\tconst {\n\t\ttype: layoutType,\n\t\tcolumnCount = 3,\n\t\tminimumColumnWidth,\n\t} = layout || {};\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst templateCategory =\n\t\t\t\tinherit &&\n\t\t\t\ttemplateSlug?.startsWith( 'category-' ) &&\n\t\t\t\tgetEntityRecords( 'taxonomy', 'category', {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\t_fields: [ 'id' ],\n\t\t\t\t\tslug: templateSlug.replace( 'category-', '' ),\n\t\t\t\t} );\n\t\t\tconst templateTag =\n\t\t\t\tinherit &&\n\t\t\t\ttemplateSlug?.startsWith( 'tag-' ) &&\n\t\t\t\tgetEntityRecords( 'taxonomy', 'post_tag', {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\t_fields: [ 'id' ],\n\t\t\t\t\tslug: templateSlug.replace( 'tag-', '' ),\n\t\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: offset || 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\t// There is no need to build the taxQuery if we inherit.\n\t\t\tif ( taxQuery && ! inherit ) {\n\t\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\t\ttype: postType,\n\t\t\t\t\tper_page: -1,\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t} );\n\t\t\t\t// Build REST API parameters from taxonomy terms, e.g.\n\t\t\t\t// `category`, `tags_exclude`.\n\t\t\t\tconst buildTaxQuery = ( terms, suffix = '' ) => {\n\t\t\t\t\treturn Object.entries( terms || {} ).reduce(\n\t\t\t\t\t\t( accumulator, [ taxonomySlug, termIds ] ) => {\n\t\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( taxonomy?.rest_base && termIds?.length ) {\n\t\t\t\t\t\t\t\taccumulator[ taxonomy.rest_base + suffix ] =\n\t\t\t\t\t\t\t\t\ttermIds;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst builtTaxQuery = buildTaxQuery( taxQuery.include );\n\t\t\t\tif ( taxQuery.exclude ) {\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\tbuiltTaxQuery,\n\t\t\t\t\t\tbuildTaxQuery( taxQuery.exclude, '_exclude' )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\tif ( format?.length ) {\n\t\t\t\tquery.format = format;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Handle cases where sticky is set to `exclude` or `only`.\n\t\t\t * Which works as a `post__in/post__not_in` query for sticky posts.\n\t\t\t */\n\t\t\tif ( [ 'exclude', 'only' ].includes( sticky ) ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\n\t\t\t// Empty string represents the default behavior of including sticky posts.\n\t\t\tif ( [ '', 'ignore' ].includes( sticky ) ) {\n\t\t\t\t// Remove any leftover sticky query parameter.\n\t\t\t\tdelete query.sticky;\n\t\t\t\tquery.ignore_sticky = sticky === 'ignore';\n\t\t\t}\n\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tlet currentPostType = postType;\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tcurrentPostType = query.postType;\n\t\t\t\t} else if ( templateCategory ) {\n\t\t\t\t\tquery.categories = templateCategory[ 0 ]?.id;\n\t\t\t\t} else if ( templateTag ) {\n\t\t\t\t\tquery.tags = templateTag[ 0 ]?.id;\n\t\t\t\t} else if (\n\t\t\t\t\ttemplateSlug?.startsWith( 'taxonomy-post_format' )\n\t\t\t\t) {\n\t\t\t\t\t// Get the post format slug from the template slug by removing the prefix.\n\t\t\t\t\tquery.format = templateSlug.replace(\n\t\t\t\t\t\t'taxonomy-post_format-post-format-',\n\t\t\t\t\t\t''\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || currentPostType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, {\n\t\t\t\t\t...query,\n\t\t\t\t\t...restQueryArgs,\n\t\t\t\t} ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tformat,\n\t\t\trestQueryArgs,\n\t\t\tpreviewPostType,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t\tclassList: post.class_list ?? '',\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( __unstableLayoutClassNames, {\n\t\t\t[ `columns-${ columnCount }` ]:\n\t\t\t\tlayoutType === 'grid' && columnCount, // Ensure column count is flagged via classname for backwards compatibility.\n\t\t\t'has-native-responsive-grid':\n\t\t\t\tlayoutType === 'grid' && columnCount && minimumColumnWidth, // Flag native responsive grid when minimum column width is provided.\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\tconst setDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tlayout: { ...layout, ...newDisplayLayout },\n\t\t} );\n\n\tconst displayLayoutControls = [\n\t\t{\n\t\t\ticon: list,\n\t\t\ttitle: _x( 'List view', 'Post template block display setting' ),\n\t\t\tonClick: () => setDisplayLayout( { type: 'default' } ),\n\t\t\tisActive: layoutType === 'default' || layoutType === 'constrained',\n\t\t},\n\t\t{\n\t\t\ticon: grid,\n\t\t\ttitle: _x( 'Grid view', 'Post template block display setting' ),\n\t\t\tonClick: () =>\n\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\ttype: 'grid',\n\t\t\t\t\tcolumnCount,\n\t\t\t\t} ),\n\t\t\tisActive: layoutType === 'grid',\n\t\t},\n\t];\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup controls={ displayLayoutControls } />\n\t\t\t</BlockControls>\n\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t{ blockContexts &&\n\t\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t\t<PostTemplateInnerBlocks\n\t\t\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\n\t\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\t\tsetActiveBlockContextId={\n\t\t\t\t\t\t\t\t\tsetActiveBlockContextId\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\t\tblockContext.postId ===\n\t\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAwC;AACxC,kBAA0B;AAC1B,kBAAuB;AACvB,0BAOO;AACP,wBAAsC;AACtC,uBAAmC;AACnC,mBAA2B;AAyBnB;AAvBR,IAAM,WAAW;AAAA,EAChB,CAAE,iBAAkB;AAAA,EACpB;AAAA,IACC;AAAA,IACA;AAAA,MACC,UAAU;AAAA,QACT,UAAU;AAAA,UACT,UAAU;AAAA,YACT,QAAQ;AAAA,YACR,MAAM,EAAE,OAAO,OAAO;AAAA,UACvB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,CAAE,mBAAoB;AACvB;AAEA,SAAS,wBAAyB,EAA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;AAAA,MAC9D,SAAS,MACR,iBAAkB;AAAA,QACjB,MAAM;AAAA,QACN;AAAA,MACD,CAAE;AAAA,MACH,UAAU,eAAe;AAAA,IAC1B;AAAA,EACD;AAMA,SACC,4EACC;AAAA,gDAAC,qCACA,sDAAC,kCAAa,UAAW,uBAAwB,GAClD;AAAA,IAEA,4CAAC,QAAK,GAAG,YACN,2BACD,cAAc,IAAK,CAAE,iBACpB;AAAA,MAAC;AAAA;AAAA,QAEA,OAAQ;AAAA,QAEN;AAAA,uBAAa,YACb,wBACD,cAAe,CAAE,GAAG,UACpB;AAAA,YAAC;AAAA;AAAA,cACA,WAAY,aAAa;AAAA;AAAA,UAC1B,IACG;AAAA,UACJ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,gBAAiB,aAAa;AAAA,cAC9B,WAAY,aAAa;AAAA,cACzB;AAAA,cAGA,UACC,aAAa,YACX,wBACD,cAAe,CAAE,GAAG;AAAA;AAAA,UAEvB;AAAA;AAAA;AAAA,MAtBM,aAAa;AAAA,IAuBpB,CACC,GACJ;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["clsx", "useBlockPreview", "coreStore", "blockEditorStore"]
|
|
7
7
|
}
|
package/build/site-logo/edit.cjs
CHANGED
|
@@ -225,13 +225,13 @@ var SiteLogo = ({
|
|
|
225
225
|
),
|
|
226
226
|
{
|
|
227
227
|
a: (
|
|
228
|
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
228
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-no-target-blank
|
|
229
229
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
230
|
"a",
|
|
231
231
|
{
|
|
232
232
|
href: siteIconSettingsUrl,
|
|
233
233
|
target: "_blank",
|
|
234
|
-
rel: "noopener
|
|
234
|
+
rel: "noopener"
|
|
235
235
|
}
|
|
236
236
|
)
|
|
237
237
|
)
|