@wordpress/block-library 8.25.0 → 8.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/build/audio/edit.js +10 -12
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +79 -32
- package/build/block/edit.js.map +1 -1
- package/build/comments-title/deprecated.js +1 -1
- package/build/comments-title/index.js +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/embed/util.js +4 -4
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.js +19 -27
- package/build/file/edit.js.map +1 -1
- package/build/gallery/edit.js +36 -17
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +3 -2
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/index.js +4 -0
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/transforms.js +4 -68
- package/build/gallery/transforms.js.map +1 -1
- package/build/group/index.js +5 -1
- package/build/group/index.js.map +1 -1
- package/build/image/deprecated.js +11 -0
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.native.js +3 -0
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +22 -21
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +7 -1
- package/build/image/view.js.map +1 -1
- package/build/list/edit.js +10 -15
- package/build/list/edit.js.map +1 -1
- package/build/list-item/edit.js +17 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/use-enter.js +5 -3
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-enter.native.js +4 -3
- package/build/list-item/hooks/use-enter.native.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +2 -3
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +1 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +3 -17
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +8 -4
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -0
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/constants.js +3 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +4 -0
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/view.js +25 -1
- package/build/navigation/view.js.map +1 -1
- package/build/pattern/edit.js +24 -2
- package/build/pattern/edit.js.map +1 -1
- package/build/pattern/recursion-detector.js +147 -0
- package/build/pattern/recursion-detector.js.map +1 -0
- package/build/post-featured-image/edit.js +19 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +4 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -1
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/search/edit.js +3 -5
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +0 -4
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +7 -6
- package/build/site-logo/edit.js.map +1 -1
- package/build/spacer/edit.native.js +2 -2
- package/build/spacer/edit.native.js.map +1 -1
- package/build/tag-cloud/edit.js +5 -9
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/utils/constants.js +16 -0
- package/build/utils/constants.js.map +1 -0
- package/build/video/edit.js +11 -8
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +10 -12
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +83 -36
- package/build-module/block/edit.js.map +1 -1
- package/build-module/comments-title/deprecated.js +1 -1
- package/build-module/comments-title/index.js +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/embed/util.js +4 -4
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.js +19 -27
- package/build-module/file/edit.js.map +1 -1
- package/build-module/gallery/edit.js +36 -17
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +3 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/index.js +4 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/transforms.js +4 -68
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/group/index.js +5 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/deprecated.js +11 -0
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.native.js +3 -0
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +17 -16
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +7 -1
- package/build-module/image/view.js.map +1 -1
- package/build-module/list/edit.js +10 -15
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list-item/edit.js +18 -3
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.js +5 -3
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.native.js +4 -3
- package/build-module/list-item/hooks/use-enter.native.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +2 -3
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +1 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +3 -17
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +8 -4
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/media-text/media-container.native.js +3 -0
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/constants.js +1 -0
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +5 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/view.js +25 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/pattern/edit.js +26 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/pattern/recursion-detector.js +139 -0
- package/build-module/pattern/recursion-detector.js.map +1 -0
- package/build-module/post-featured-image/edit.js +19 -2
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +4 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +3 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/search/edit.js +3 -5
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +0 -4
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +7 -6
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +2 -2
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/tag-cloud/edit.js +6 -10
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/utils/constants.js +9 -0
- package/build-module/utils/constants.js.map +1 -0
- package/build-module/video/edit.js +11 -8
- package/build-module/video/edit.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -37
- package/build-style/button/editor.css +0 -37
- package/build-style/button/style-rtl.css +6 -6
- package/build-style/button/style.css +6 -6
- package/build-style/editor-rtl.css +2 -44
- package/build-style/editor.css +2 -44
- package/build-style/navigation/editor-rtl.css +2 -4
- package/build-style/navigation/editor.css +2 -4
- package/build-style/navigation/style-rtl.css +14 -18
- package/build-style/navigation/style.css +14 -18
- package/build-style/search/style-rtl.css +26 -27
- package/build-style/search/style.css +26 -27
- package/build-style/style-rtl.css +46 -51
- package/build-style/style.css +46 -51
- package/build-style/table/editor-rtl.css +0 -3
- package/build-style/table/editor.css +0 -3
- package/package.json +32 -32
- package/src/audio/edit.js +19 -19
- package/src/audio/test/__snapshots__/edit.native.js.snap +12 -0
- package/src/audio/test/edit.native.js +29 -0
- package/src/block/edit.js +114 -60
- package/src/button/editor.scss +0 -43
- package/src/button/style.scss +6 -6
- package/src/comments-title/block.json +1 -1
- package/src/cover/edit/inspector-controls.js +1 -1
- package/src/embed/util.js +2 -2
- package/src/file/edit.js +17 -24
- package/src/gallery/block.json +4 -0
- package/src/gallery/edit.js +69 -42
- package/src/gallery/gallery.js +4 -1
- package/src/gallery/index.php +18 -0
- package/src/gallery/transforms.js +2 -55
- package/src/group/block.json +5 -1
- package/src/image/deprecated.js +8 -0
- package/src/image/edit.native.js +3 -0
- package/src/image/image.js +54 -35
- package/src/image/index.php +1 -6
- package/src/image/view.js +5 -2
- package/src/list/edit.js +27 -35
- package/src/list-item/edit.js +18 -2
- package/src/list-item/hooks/use-enter.js +63 -62
- package/src/list-item/hooks/use-enter.native.js +9 -5
- package/src/list-item/hooks/use-indent-list-item.js +43 -53
- package/src/list-item/hooks/use-merge.js +1 -1
- package/src/list-item/hooks/use-outdent-list-item.js +50 -69
- package/src/list-item/hooks/use-space.js +7 -4
- package/src/media-text/media-container.native.js +3 -1
- package/src/navigation/constants.js +2 -0
- package/src/navigation/edit/index.js +11 -1
- package/src/navigation/editor.scss +1 -1
- package/src/navigation/style.scss +18 -16
- package/src/navigation/view.js +29 -3
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +12 -0
- package/src/paragraph/test/edit.native.js +114 -0
- package/src/pattern/edit.js +35 -3
- package/src/pattern/index.php +16 -0
- package/src/pattern/recursion-detector.js +145 -0
- package/src/pattern/test/index.js +74 -0
- package/src/post-featured-image/block.json +4 -0
- package/src/post-featured-image/edit.js +32 -1
- package/src/post-featured-image/index.php +31 -0
- package/src/query/edit/inspector-controls/index.js +2 -0
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/search/block.json +0 -4
- package/src/search/edit.js +2 -8
- package/src/search/index.php +3 -7
- package/src/search/style.scss +27 -29
- package/src/site-logo/edit.js +3 -4
- package/src/social-link/index.php +1 -1
- package/src/spacer/edit.native.js +4 -2
- package/src/table/editor.scss +0 -3
- package/src/tag-cloud/edit.js +7 -7
- package/src/template-part/index.php +6 -0
- package/src/utils/constants.js +8 -0
- package/src/video/edit.js +29 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cloneBlock","useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockProps","coreStore","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","currentThemeStylesheet","getCurrentTheme","stylesheet","replaceBlocks","setBlockEditingMode","__unstableMarkNextChangeAsNotPersistent","getBlockRootClientId","getBlockEditingMode","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","blocks","window","queueMicrotask","rootClientId","clonedBlocks","rootEditingMode","props","createElement"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern
|
|
1
|
+
{"version":3,"names":["cloneBlock","useSelect","useDispatch","useState","useEffect","Warning","store","blockEditorStore","useBlockProps","coreStore","__","sprintf","useParsePatternDependencies","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","currentThemeStylesheet","getCurrentTheme","stylesheet","replaceBlocks","setBlockEditingMode","__unstableMarkNextChangeAsNotPersistent","getBlockRootClientId","getBlockEditingMode","hasRecursionError","setHasRecursionError","parsePatternDependencies","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","blocks","error","window","queueMicrotask","rootClientId","clonedBlocks","rootEditingMode","props","createElement"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tWarning,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useParsePatternDependencies } from './recursion-detector';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst [ hasRecursionError, setHasRecursionError ] = useState( false );\n\tconst parsePatternDependencies = useParsePatternDependencies();\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( ! hasRecursionError && selectedPattern?.blocks ) {\n\t\t\ttry {\n\t\t\t\tparsePatternDependencies( selectedPattern );\n\t\t\t} catch ( error ) {\n\t\t\t\tsetHasRecursionError( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\thasRecursionError,\n\t\tselectedPattern,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\tif ( hasRecursionError ) {\n\t\treturn (\n\t\t\t<div { ...props }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: A warning in which %s is the name of a pattern.\n\t\t\t\t\t\t__( 'Pattern \"%s\" cannot be rendered inside itself.' ),\n\t\t\t\t\t\tselectedPattern?.name\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n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D,mBAAmB,CAAEoB,YAAY,EAAEE,eAAgB,CAAC;MACrD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACF/B,QAAQ,EACRa,iBAAiB,EACjBZ,eAAe,EACfS,uCAAuC,EACvCF,aAAa,EACbI,mBAAmB,EACnBH,mBAAmB,EACnBE,oBAAoB,CACnB,CAAC;EAEH,MAAMqB,KAAK,GAAGvC,aAAa,CAAC,CAAC;EAE7B,IAAKoB,iBAAiB,EAAG;IACxB,OACCoB,aAAA;MAAA,GAAUD;IAAK,GACdC,aAAA,CAAC3C,OAAO,QACLM,OAAO;IACR;IACAD,EAAE,CAAE,gDAAiD,CAAC,EACtDM,eAAe,EAAEoB,IAClB,CACQ,CACL,CAAC;EAER;EAEA,OAAOY,aAAA;IAAA,GAAUD;EAAK,CAAI,CAAC;AAC5B,CAAC;AAED,eAAelC,WAAW"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.
|
|
3
|
+
*
|
|
4
|
+
* This is because this approach for preventing infinite loops due to
|
|
5
|
+
* recursively rendering blocks is specific to the way that the `core/pattern`
|
|
6
|
+
* block behaves in the editor. Any other block types that deal with recursion
|
|
7
|
+
* SHOULD USE THE STANDARD METHOD for avoiding loops:
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/WordPress/gutenberg/pull/31455
|
|
10
|
+
* @see packages/block-editor/src/components/recursion-provider/README.md
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { useRegistry } from '@wordpress/data';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Naming is hard.
|
|
20
|
+
*
|
|
21
|
+
* @see useParsePatternDependencies
|
|
22
|
+
*
|
|
23
|
+
* @type {WeakMap<Object, Function>}
|
|
24
|
+
*/
|
|
25
|
+
const cachedParsers = new WeakMap();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Hook used by PatternEdit to parse block patterns. It returns a function that
|
|
29
|
+
* takes a pattern and returns nothing but throws an error if the pattern is
|
|
30
|
+
* recursive.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* const parsePatternDependencies = useParsePatternDependencies();
|
|
35
|
+
* parsePatternDependencies( selectedPattern );
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @see parsePatternDependencies
|
|
39
|
+
*
|
|
40
|
+
* @return {Function} A function to parse block patterns.
|
|
41
|
+
*/
|
|
42
|
+
export function useParsePatternDependencies() {
|
|
43
|
+
const registry = useRegistry();
|
|
44
|
+
|
|
45
|
+
// Instead of caching maps, go straight to the point and cache bound
|
|
46
|
+
// functions. Each of those functions is bound to a different Map that will
|
|
47
|
+
// keep track of patterns in the context of the given registry.
|
|
48
|
+
if (!cachedParsers.has(registry)) {
|
|
49
|
+
const deps = new Map();
|
|
50
|
+
cachedParsers.set(registry, parsePatternDependencies.bind(null, deps));
|
|
51
|
+
}
|
|
52
|
+
return cachedParsers.get(registry);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parse a given pattern and traverse its contents to detect any subsequent
|
|
57
|
+
* patterns on which it may depend. Such occurrences will be added to an
|
|
58
|
+
* internal dependency graph. If a circular dependency is detected, an
|
|
59
|
+
* error will be thrown.
|
|
60
|
+
*
|
|
61
|
+
* EXPORTED FOR TESTING PURPOSES ONLY.
|
|
62
|
+
*
|
|
63
|
+
* @param {Map<string, Set<string>>} deps Map of pattern dependencies.
|
|
64
|
+
* @param {Object} pattern Pattern.
|
|
65
|
+
* @param {string} pattern.name Pattern name.
|
|
66
|
+
* @param {Array} pattern.blocks Pattern's block list.
|
|
67
|
+
*
|
|
68
|
+
* @throws {Error} If a circular dependency is detected.
|
|
69
|
+
*/
|
|
70
|
+
export function parsePatternDependencies(deps, {
|
|
71
|
+
name,
|
|
72
|
+
blocks
|
|
73
|
+
}) {
|
|
74
|
+
const queue = [...blocks];
|
|
75
|
+
while (queue.length) {
|
|
76
|
+
const block = queue.shift();
|
|
77
|
+
for (const innerBlock of (_block$innerBlocks = block.innerBlocks) !== null && _block$innerBlocks !== void 0 ? _block$innerBlocks : []) {
|
|
78
|
+
var _block$innerBlocks;
|
|
79
|
+
queue.unshift(innerBlock);
|
|
80
|
+
}
|
|
81
|
+
if (block.name === 'core/pattern') {
|
|
82
|
+
registerDependency(deps, name, block.attributes.slug);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Declare that pattern `a` depends on pattern `b`. If a circular
|
|
89
|
+
* dependency is detected, an error will be thrown.
|
|
90
|
+
*
|
|
91
|
+
* EXPORTED FOR TESTING PURPOSES ONLY.
|
|
92
|
+
*
|
|
93
|
+
* @param {Map<string, Set<string>>} deps Map of pattern dependencies.
|
|
94
|
+
* @param {string} a Slug for pattern A.
|
|
95
|
+
* @param {string} b Slug for pattern B.
|
|
96
|
+
*
|
|
97
|
+
* @throws {Error} If a circular dependency is detected.
|
|
98
|
+
*/
|
|
99
|
+
export function registerDependency(deps, a, b) {
|
|
100
|
+
if (!deps.has(a)) {
|
|
101
|
+
deps.set(a, new Set());
|
|
102
|
+
}
|
|
103
|
+
deps.get(a).add(b);
|
|
104
|
+
if (hasCycle(deps, a)) {
|
|
105
|
+
throw new TypeError(`Pattern ${a} has a circular dependency and cannot be rendered.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Determine if a given pattern has circular dependencies on other patterns.
|
|
111
|
+
* This will be determined by running a depth-first search on the current state
|
|
112
|
+
* of the graph represented by `patternDependencies`.
|
|
113
|
+
*
|
|
114
|
+
* @param {Map<string, Set<string>>} deps Map of pattern dependencies.
|
|
115
|
+
* @param {string} slug Pattern slug.
|
|
116
|
+
* @param {Set<string>} [visitedNodes] Set to track visited nodes in the graph.
|
|
117
|
+
* @param {Set<string>} [currentPath] Set to track and backtrack graph paths.
|
|
118
|
+
* @return {boolean} Whether any cycle was found.
|
|
119
|
+
*/
|
|
120
|
+
function hasCycle(deps, slug, visitedNodes = new Set(), currentPath = new Set()) {
|
|
121
|
+
var _deps$get;
|
|
122
|
+
visitedNodes.add(slug);
|
|
123
|
+
currentPath.add(slug);
|
|
124
|
+
const dependencies = (_deps$get = deps.get(slug)) !== null && _deps$get !== void 0 ? _deps$get : new Set();
|
|
125
|
+
for (const dependency of dependencies) {
|
|
126
|
+
if (!visitedNodes.has(dependency)) {
|
|
127
|
+
if (hasCycle(deps, dependency, visitedNodes, currentPath)) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
} else if (currentPath.has(dependency)) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Remove the current node from the current path when backtracking
|
|
136
|
+
currentPath.delete(slug);
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=recursion-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useRegistry","cachedParsers","WeakMap","useParsePatternDependencies","registry","has","deps","Map","set","parsePatternDependencies","bind","get","name","blocks","queue","length","block","shift","innerBlock","_block$innerBlocks","innerBlocks","unshift","registerDependency","attributes","slug","a","b","Set","add","hasCycle","TypeError","visitedNodes","currentPath","_deps$get","dependencies","dependency","delete"],"sources":["@wordpress/block-library/src/pattern/recursion-detector.js"],"sourcesContent":["/**\n * THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.\n *\n * This is because this approach for preventing infinite loops due to\n * recursively rendering blocks is specific to the way that the `core/pattern`\n * block behaves in the editor. Any other block types that deal with recursion\n * SHOULD USE THE STANDARD METHOD for avoiding loops:\n *\n * @see https://github.com/WordPress/gutenberg/pull/31455\n * @see packages/block-editor/src/components/recursion-provider/README.md\n */\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Naming is hard.\n *\n * @see useParsePatternDependencies\n *\n * @type {WeakMap<Object, Function>}\n */\nconst cachedParsers = new WeakMap();\n\n/**\n * Hook used by PatternEdit to parse block patterns. It returns a function that\n * takes a pattern and returns nothing but throws an error if the pattern is\n * recursive.\n *\n * @example\n * ```js\n * const parsePatternDependencies = useParsePatternDependencies();\n * parsePatternDependencies( selectedPattern );\n * ```\n *\n * @see parsePatternDependencies\n *\n * @return {Function} A function to parse block patterns.\n */\nexport function useParsePatternDependencies() {\n\tconst registry = useRegistry();\n\n\t// Instead of caching maps, go straight to the point and cache bound\n\t// functions. Each of those functions is bound to a different Map that will\n\t// keep track of patterns in the context of the given registry.\n\tif ( ! cachedParsers.has( registry ) ) {\n\t\tconst deps = new Map();\n\t\tcachedParsers.set(\n\t\t\tregistry,\n\t\t\tparsePatternDependencies.bind( null, deps )\n\t\t);\n\t}\n\treturn cachedParsers.get( registry );\n}\n\n/**\n * Parse a given pattern and traverse its contents to detect any subsequent\n * patterns on which it may depend. Such occurrences will be added to an\n * internal dependency graph. If a circular dependency is detected, an\n * error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {Object} pattern Pattern.\n * @param {string} pattern.name Pattern name.\n * @param {Array} pattern.blocks Pattern's block list.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function parsePatternDependencies( deps, { name, blocks } ) {\n\tconst queue = [ ...blocks ];\n\twhile ( queue.length ) {\n\t\tconst block = queue.shift();\n\t\tfor ( const innerBlock of block.innerBlocks ?? [] ) {\n\t\t\tqueue.unshift( innerBlock );\n\t\t}\n\t\tif ( block.name === 'core/pattern' ) {\n\t\t\tregisterDependency( deps, name, block.attributes.slug );\n\t\t}\n\t}\n}\n\n/**\n * Declare that pattern `a` depends on pattern `b`. If a circular\n * dependency is detected, an error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} a Slug for pattern A.\n * @param {string} b Slug for pattern B.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function registerDependency( deps, a, b ) {\n\tif ( ! deps.has( a ) ) {\n\t\tdeps.set( a, new Set() );\n\t}\n\tdeps.get( a ).add( b );\n\tif ( hasCycle( deps, a ) ) {\n\t\tthrow new TypeError(\n\t\t\t`Pattern ${ a } has a circular dependency and cannot be rendered.`\n\t\t);\n\t}\n}\n\n/**\n * Determine if a given pattern has circular dependencies on other patterns.\n * This will be determined by running a depth-first search on the current state\n * of the graph represented by `patternDependencies`.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} slug Pattern slug.\n * @param {Set<string>} [visitedNodes] Set to track visited nodes in the graph.\n * @param {Set<string>} [currentPath] Set to track and backtrack graph paths.\n * @return {boolean} Whether any cycle was found.\n */\nfunction hasCycle(\n\tdeps,\n\tslug,\n\tvisitedNodes = new Set(),\n\tcurrentPath = new Set()\n) {\n\tvisitedNodes.add( slug );\n\tcurrentPath.add( slug );\n\n\tconst dependencies = deps.get( slug ) ?? new Set();\n\n\tfor ( const dependency of dependencies ) {\n\t\tif ( ! visitedNodes.has( dependency ) ) {\n\t\t\tif ( hasCycle( deps, dependency, visitedNodes, currentPath ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if ( currentPath.has( dependency ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Remove the current node from the current path when backtracking\n\tcurrentPath.delete( slug );\n\treturn false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,IAAIC,OAAO,CAAC,CAAC;;A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ityProp, store as coreStore } from '@wordpress/core-data';
|
|
|
11
11
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
12
|
import { MenuItem, ToggleControl, PanelBody, Placeholder, Button, TextControl } from '@wordpress/components';
|
|
13
13
|
import { InspectorControls, BlockControls, MediaPlaceholder, MediaReplaceFlow, useBlockProps, store as blockEditorStore, __experimentalUseBorderProps as useBorderProps } from '@wordpress/block-editor';
|
|
14
|
+
import { useMemo } from '@wordpress/element';
|
|
14
15
|
import { __, sprintf } from '@wordpress/i18n';
|
|
15
16
|
import { upload } from '@wordpress/icons';
|
|
16
17
|
import { store as noticesStore } from '@wordpress/notices';
|
|
@@ -47,9 +48,25 @@ export default function PostFeaturedImageEdit({
|
|
|
47
48
|
scale,
|
|
48
49
|
sizeSlug,
|
|
49
50
|
rel,
|
|
50
|
-
linkTarget
|
|
51
|
+
linkTarget,
|
|
52
|
+
useFirstImageFromPost
|
|
51
53
|
} = attributes;
|
|
52
|
-
const [
|
|
54
|
+
const [storedFeaturedImage, setFeaturedImage] = useEntityProp('postType', postTypeSlug, 'featured_media', postId);
|
|
55
|
+
|
|
56
|
+
// Fallback to post content if no featured image is set.
|
|
57
|
+
// This is needed for the "Use first image from post" option.
|
|
58
|
+
const [postContent] = useEntityProp('postType', postTypeSlug, 'content', postId);
|
|
59
|
+
const featuredImage = useMemo(() => {
|
|
60
|
+
if (storedFeaturedImage) {
|
|
61
|
+
return storedFeaturedImage;
|
|
62
|
+
}
|
|
63
|
+
if (!useFirstImageFromPost) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const imageOpener = /<!--\s+wp:(?:core\/)?image\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\s+\/?-->).)*)?}\s+)?-->/.exec(postContent);
|
|
67
|
+
const imageId = imageOpener?.groups?.attrs && JSON.parse(imageOpener.groups.attrs)?.id;
|
|
68
|
+
return imageId;
|
|
69
|
+
}, [storedFeaturedImage, useFirstImageFromPost, postContent]);
|
|
53
70
|
const {
|
|
54
71
|
media,
|
|
55
72
|
postType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useEntityProp","store","coreStore","useSelect","useDispatch","MenuItem","ToggleControl","PanelBody","Placeholder","Button","TextControl","InspectorControls","BlockControls","MediaPlaceholder","MediaReplaceFlow","useBlockProps","blockEditorStore","__experimentalUseBorderProps","useBorderProps","__","sprintf","upload","noticesStore","DimensionControls","Overlay","ALLOWED_MEDIA_TYPES","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","disabledClickProps","onClick","event","preventDefault","PostFeaturedImageEdit","clientId","attributes","setAttributes","context","postId","postType","postTypeSlug","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","aspectRatio","height","width","scale","sizeSlug","rel","linkTarget","featuredImage","setFeaturedImage","postPermalink","select","getMedia","getPostType","getEditedEntityRecord","link","mediaUrl","imageSizes","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","style","borderProps","placeholder","content","createElement","className","withIllustration","onSelectImage","id","createErrorNotice","onUploadError","message","type","controls","Fragment","title","__nextHasNoMarginBottom","labels","singular_name","onChange","checked","newRel","image","href","target","imageStyles","objectFit","onSelect","accept","allowedTypes","onError","mediaLibraryButton","open","icon","variant","showTooltip","tooltipPosition","src","alt","alt_text","group","mediaId","mediaURL"],"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\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 Overlay from './overlay';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nconst disabledClickProps = {\n\tonClick: ( event ) => event.preventDefault(),\n\t'aria-disabled': true,\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} = attributes;\n\tconst [ featuredImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst { media, postType, postPermalink } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia, 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\tgetMedia( 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 = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height, aspectRatio },\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames(\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={ true }\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} }\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\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Page\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\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={ __( 'Open in new tab' ) }\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\tlinkTarget: value ? '_blank' : '_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\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\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 consious 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\n\t\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t\t>\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\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 ) {\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\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 = ! media ? (\n\t\t\tplaceholder()\n\t\t) : (\n\t\t\t<img\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ imageStyles }\n\t\t\t/>\n\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{ 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>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\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\n\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t>\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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,aAAa,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACxE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,QAAQ,EACRC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,WAAW,QACL,uBAAuB;AAC9B,SACCC,iBAAiB,EACjBC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,EAChBC,aAAa,EACbd,KAAK,IAAIe,gBAAgB,EACzBC,4BAA4B,IAAIC,cAAc,QACxC,yBAAyB;AAChC,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASpB,KAAK,IAAIqB,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,sBAAsB;AACpD,OAAOC,OAAO,MAAM,WAAW;AAE/B,MAAMC,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAEvC,SAASC,2BAA2BA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACnD,OACCD,KAAK,EAAEE,aAAa,EAAEC,KAAK,GAAIF,IAAI,CAAE,EAAEG,UAAU,IAAIJ,KAA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KACA,CAAC,GAEJA,KACA,EACDlB,aAAA,CAACtD,OAAO;IACPc,UAAU,EAAGA,UAAY;IACzBC,aAAa,EAAGA,aAAe;IAC/BF,QAAQ,EAAGA;EAAU,CACrB,CACM,CACP,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["classnames","useEntityProp","store","coreStore","useSelect","useDispatch","MenuItem","ToggleControl","PanelBody","Placeholder","Button","TextControl","InspectorControls","BlockControls","MediaPlaceholder","MediaReplaceFlow","useBlockProps","blockEditorStore","__experimentalUseBorderProps","useBorderProps","useMemo","__","sprintf","upload","noticesStore","DimensionControls","Overlay","ALLOWED_MEDIA_TYPES","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","disabledClickProps","onClick","event","preventDefault","PostFeaturedImageEdit","clientId","attributes","setAttributes","context","postId","postType","postTypeSlug","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","aspectRatio","height","width","scale","sizeSlug","rel","linkTarget","useFirstImageFromPost","storedFeaturedImage","setFeaturedImage","postContent","featuredImage","imageOpener","exec","imageId","groups","attrs","JSON","parse","id","postPermalink","select","getMedia","getPostType","getEditedEntityRecord","link","mediaUrl","imageSizes","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","style","borderProps","placeholder","content","createElement","className","withIllustration","onSelectImage","createErrorNotice","onUploadError","message","type","controls","Fragment","title","__nextHasNoMarginBottom","labels","singular_name","onChange","checked","newRel","image","href","target","imageStyles","objectFit","onSelect","accept","allowedTypes","onError","mediaLibraryButton","open","icon","variant","showTooltip","tooltipPosition","src","alt","alt_text","group","mediaId","mediaURL"],"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { useMemo } 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 Overlay from './overlay';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nconst disabledClickProps = {\n\tonClick: ( event ) => event.preventDefault(),\n\t'aria-disabled': true,\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\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 { getMedia, 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\tgetMedia( 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 = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height, aspectRatio },\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames(\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={ true }\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} }\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\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Page\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\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={ __( 'Open in new tab' ) }\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\tlinkTarget: value ? '_blank' : '_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\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\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 consious 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\n\t\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t\t>\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\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 ) {\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\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 = ! media ? (\n\t\t\tplaceholder()\n\t\t) : (\n\t\t\t<img\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ imageStyles }\n\t\t\t/>\n\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{ 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>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\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\n\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t>\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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,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AQ,CACL,CACO,CACJ,CACf,EACDsE,aAAA;IAAA,GAAaL;EAAU,GAEpB,CAAC,CAAEpC,MAAM,GACVyC,aAAA;IACCkB,IAAI,EAAGtC,aAAe;IACtBuC,MAAM,EAAGrD,UAAY;IAAA,GAChBvB;EAAkB,GAErB0E,KACA,CAAC,GAEJA,KACA,EACDjB,aAAA,CAACjE,OAAO;IACPc,UAAU,EAAGA,UAAY;IACzBC,aAAa,EAAGA,aAAe;IAC/BF,QAAQ,EAAGA;EAAU,CACrB,CACM,CACP,CAAC;AAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["postFeaturedImage","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","isLink","type","aspectRatio","width","height","scale","sizeSlug","rel","attribute","linkTarget","overlayColor","customOverlayColor","dimRatio","gradient","customGradient","usesContext","supports","align","color","__experimentalDuotone","text","background","__experimentalBorder","radius","__experimentalSelector","__experimentalSkipSerialization","__experimentalDefaultControls","html","spacing","margin","padding","editorStyle","style","edit","settings","init"],"sources":["@wordpress/block-library/src/post-featured-image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postFeaturedImage as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,IAAIC,IAAI,QAAQ,kBAAkB;;AAE5D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,MAAA;MAAAC,IAAA;MAAA;IAAA;IAAAC,WAAA;MAAAD,IAAA;IAAA;IAAAE,KAAA;MAAAF,IAAA;IAAA;IAAAG,MAAA;MAAAH,IAAA;IAAA;IAAAI,KAAA;MAAAJ,IAAA;MAAA;IAAA;IAAAK,QAAA;MAAAL,IAAA;IAAA;IAAAM,GAAA;MAAAN,IAAA;MAAAO,SAAA;MAAA;IAAA;IAAAC,UAAA;MAAAR,IAAA;MAAA;IAAA;IAAAS,YAAA;MAAAT,IAAA;IAAA;IAAAU,kBAAA;MAAAV,IAAA;IAAA;IAAAW,QAAA;MAAAX,IAAA;MAAA;IAAA;IAAAY,QAAA;MAAAZ,IAAA;IAAA;IAAAa,cAAA;MAAAb,IAAA;IAAA;EAAA;
|
|
1
|
+
{"version":3,"names":["postFeaturedImage","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","isLink","type","aspectRatio","width","height","scale","sizeSlug","rel","attribute","linkTarget","overlayColor","customOverlayColor","dimRatio","gradient","customGradient","useFirstImageFromPost","usesContext","supports","align","color","__experimentalDuotone","text","background","__experimentalBorder","radius","__experimentalSelector","__experimentalSkipSerialization","__experimentalDefaultControls","html","spacing","margin","padding","editorStyle","style","edit","settings","init"],"sources":["@wordpress/block-library/src/post-featured-image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postFeaturedImage as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAiB,IAAIC,IAAI,QAAQ,kBAAkB;;AAE5D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,U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|
import CreateNewPostLink from './create-new-post-link';
|
|
21
21
|
import { unlock } from '../../../lock-unlock';
|
|
22
22
|
import { usePostTypes, useIsPostTypeHierarchical, useAllowedControls, isControlAllowed, useTaxonomies } from '../../utils';
|
|
23
|
+
import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../../../utils/constants';
|
|
23
24
|
const {
|
|
24
25
|
BlockInfo
|
|
25
26
|
} = unlock(blockEditorPrivateApis);
|
|
@@ -156,7 +157,8 @@ export default function QueryInspectorControls(props) {
|
|
|
156
157
|
taxQuery: null
|
|
157
158
|
});
|
|
158
159
|
setQuerySearch('');
|
|
159
|
-
}
|
|
160
|
+
},
|
|
161
|
+
dropdownMenuProps: TOOLSPANEL_DROPDOWNMENU_PROPS
|
|
160
162
|
}, showTaxControl && createElement(ToolsPanelItem, {
|
|
161
163
|
label: __('Taxonomies'),
|
|
162
164
|
hasValue: () => Object.values(taxQuery || {}).some(terms => !!terms.length),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PanelBody","TextControl","SelectControl","RangeControl","ToggleControl","Notice","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","InspectorControls","privateApis","blockEditorPrivateApis","debounce","useEffect","useState","useCallback","OrderControl","AuthorControl","ParentControl","TaxonomyControls","StickyControl","EnhancedPaginationControl","CreateNewPostLink","unlock","usePostTypes","useIsPostTypeHierarchical","useAllowedControls","isControlAllowed","useTaxonomies","BlockInfo","QueryInspectorControls","props","attributes","setQuery","setDisplayLayout","setAttributes","clientId","query","displayLayout","enhancedPagination","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomies","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","showOrderControl","showStickyControl","showSettingsPanel","showTaxControl","showAuthorControl","showSearchControl","showParentControl","showFiltersPanel","createElement","Fragment","title","__nextHasNoMarginBottom","label","help","checked","onChange","value","options","columns","min","max","Math","status","isDismissible","className","resetAll","hasValue","values","some","onDeselect"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport EnhancedPaginationControl from './enhanced-pagination-control';\nimport CreateNewPostLink from './create-new-post-link';\nimport { unlock } from '../../../lock-unlock';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n\tuseTaxonomies,\n} from '../../utils';\n\nconst { BlockInfo } = unlock( blockEditorPrivateApis );\n\nexport default function QueryInspectorControls( props ) {\n\tconst { attributes, setQuery, setDisplayLayout, setAttributes, clientId } =\n\t\tprops;\n\tconst { query, displayLayout, enhancedPagination } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomies = useTaxonomies( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = false;\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\tconst showTaxControl =\n\t\t!! taxonomies?.length &&\n\t\tisControlAllowed( allowedControls, 'taxQuery' );\n\tconst showAuthorControl = isControlAllowed( allowedControls, 'author' );\n\tconst showSearchControl = isControlAllowed( allowedControls, 'search' );\n\tconst showParentControl =\n\t\tisControlAllowed( allowedControls, 'parents' ) &&\n\t\tisPostTypeHierarchical;\n\n\tconst showFiltersPanel =\n\t\tshowTaxControl ||\n\t\tshowAuthorControl ||\n\t\tshowSearchControl ||\n\t\tshowParentControl;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockInfo>\n\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t</BlockInfo>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\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={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! 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\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\t\t\tcolumns: value,\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\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: 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\t<EnhancedPaginationControl\n\t\t\t\t\t\t\tenhancedPagination={ enhancedPagination }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && showFiltersPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTaxControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\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\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: 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\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\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{ showAuthorControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\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{ showSearchControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\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__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\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{ showParentControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\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</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;;AAErE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,yBAAyB,MAAM,+BAA+B;AACrE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SACCC,YAAY,EACZC,yBAAyB,EACzBC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa,QACP,aAAa;AAEpB,MAAM;EAAEC;AAAU,CAAC,GAAGN,MAAM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MpC,cAAc,CAAE,EAAG;EAAG,GAEzCe,aAAA,CAACxF,WAAW;IACX2F,uBAAuB;IACvBC,KAAK,EAAGnF,EAAE,CAAE,SAAU,CAAG;IACzBuF,KAAK,EAAGxB,WAAa;IACrBuB,QAAQ,EAAGtB;EAAgB,CAC3B,CACc,CAChB,EACCa,iBAAiB,IAClBE,aAAA,CAAChF,cAAc;IACdkG,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEzD,OAAO,EAAEqB,MAAQ;IACrCsB,KAAK,EAAGnF,EAAE,CAAE,SAAU,CAAG;IACzBoG,UAAU,EAAGA,CAAA,KAAM3E,QAAQ,CAAE;MAAEe,OAAO,EAAE;IAAG,CAAE;EAAG,GAEhDuC,aAAA,CAACrE,aAAa;IACb8B,OAAO,EAAGA,OAAS;IACnBJ,QAAQ,EAAGA,QAAU;IACrBkD,QAAQ,EAAG7D;EAAU,CACrB,CACc,CAEN,CACM,CAEnB,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["PanelBody","TextControl","SelectControl","RangeControl","ToggleControl","Notice","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","InspectorControls","privateApis","blockEditorPrivateApis","debounce","useEffect","useState","useCallback","OrderControl","AuthorControl","ParentControl","TaxonomyControls","StickyControl","EnhancedPaginationControl","CreateNewPostLink","unlock","usePostTypes","useIsPostTypeHierarchical","useAllowedControls","isControlAllowed","useTaxonomies","TOOLSPANEL_DROPDOWNMENU_PROPS","BlockInfo","QueryInspectorControls","props","attributes","setQuery","setDisplayLayout","setAttributes","clientId","query","displayLayout","enhancedPagination","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomies","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","showOrderControl","showStickyControl","showSettingsPanel","showTaxControl","showAuthorControl","showSearchControl","showParentControl","showFiltersPanel","createElement","Fragment","title","__nextHasNoMarginBottom","label","help","checked","onChange","value","options","columns","min","max","Math","status","isDismissible","className","resetAll","dropdownMenuProps","hasValue","values","some","onDeselect"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport EnhancedPaginationControl from './enhanced-pagination-control';\nimport CreateNewPostLink from './create-new-post-link';\nimport { unlock } from '../../../lock-unlock';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n\tuseTaxonomies,\n} from '../../utils';\nimport { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../../../utils/constants';\n\nconst { BlockInfo } = unlock( blockEditorPrivateApis );\n\nexport default function QueryInspectorControls( props ) {\n\tconst { attributes, setQuery, setDisplayLayout, setAttributes, clientId } =\n\t\tprops;\n\tconst { query, displayLayout, enhancedPagination } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomies = useTaxonomies( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = false;\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\tconst showTaxControl =\n\t\t!! taxonomies?.length &&\n\t\tisControlAllowed( allowedControls, 'taxQuery' );\n\tconst showAuthorControl = isControlAllowed( allowedControls, 'author' );\n\tconst showSearchControl = isControlAllowed( allowedControls, 'search' );\n\tconst showParentControl =\n\t\tisControlAllowed( allowedControls, 'parents' ) &&\n\t\tisPostTypeHierarchical;\n\n\tconst showFiltersPanel =\n\t\tshowTaxControl ||\n\t\tshowAuthorControl ||\n\t\tshowSearchControl ||\n\t\tshowParentControl;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockInfo>\n\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t</BlockInfo>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\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={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! 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\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\t\t\tcolumns: value,\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\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: 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\t<EnhancedPaginationControl\n\t\t\t\t\t\t\tenhancedPagination={ enhancedPagination }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && showFiltersPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTaxControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\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\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: 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\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\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{ showAuthorControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\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{ showSearchControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\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__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\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{ showParentControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\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</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;;AAErE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,yBAAyB,MAAM,+BAA+B;AACrE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,MAAM,QAA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ACnBmD,QAAQ,EAAG7D;EAAU,CACrB,CACc,CAChB,EACCmD,iBAAiB,IAClBG,aAAA,CAACjF,cAAc;IACdoG,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEnC,WAAa;IACjCoB,KAAK,EAAGpF,EAAE,CAAE,SAAU,CAAG;IACzBsG,UAAU,EAAGA,CAAA,KAAMrC,cAAc,CAAE,EAAG;EAAG,GAEzCe,aAAA,CAACzF,WAAW;IACX4F,uBAAuB;IACvBC,KAAK,EAAGpF,EAAE,CAAE,SAAU,CAAG;IACzBwF,KAAK,EAAGxB,WAAa;IACrBuB,QAAQ,EAAGtB;EAAgB,CAC3B,CACc,CAChB,EACCa,iBAAiB,IAClBE,aAAA,CAACjF,cAAc;IACdoG,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAE1D,OAAO,EAAEqB,MAAQ;IACrCsB,KAAK,EAAGpF,EAAE,CAAE,SAAU,CAAG;IACzBsG,UAAU,EAAGA,CAAA,KAAM5E,QAAQ,CAAE;MAAEe,OAAO,EAAE;IAAG,CAAE;EAAG,GAEhDuC,aAAA,CAACtE,aAAa;IACb+B,OAAO,EAAGA,OAAS;IACnBJ,QAAQ,EAAGA,QAAU;IACrBkD,QAAQ,EAAG7D;EAAU,CACrB,CACc,CAEN,CACM,CAEnB,CAAC;AAEL"}
|
|
@@ -14,7 +14,7 @@ const metadata = {
|
|
|
14
14
|
title: "Page Numbers",
|
|
15
15
|
category: "theme",
|
|
16
16
|
parent: ["core/query-pagination"],
|
|
17
|
-
description: "Displays a list of page numbers for pagination",
|
|
17
|
+
description: "Displays a list of page numbers for pagination.",
|
|
18
18
|
textdomain: "default",
|
|
19
19
|
attributes: {
|
|
20
20
|
midSize: {
|
|
@@ -25,7 +25,6 @@ import { PC_WIDTH_DEFAULT, PX_WIDTH_DEFAULT, MIN_WIDTH, isPercentageUnit } from
|
|
|
25
25
|
// Used to calculate border radius adjustment to avoid "fat" corners when
|
|
26
26
|
// button is placed inside wrapper.
|
|
27
27
|
const DEFAULT_INNER_PADDING = '4px';
|
|
28
|
-
const BUTTON_BEHAVIOR_EXPAND = 'expand-searchfield';
|
|
29
28
|
export default function SearchEdit({
|
|
30
29
|
className,
|
|
31
30
|
attributes,
|
|
@@ -44,7 +43,6 @@ export default function SearchEdit({
|
|
|
44
43
|
buttonText,
|
|
45
44
|
buttonPosition,
|
|
46
45
|
buttonUseIcon,
|
|
47
|
-
buttonBehavior,
|
|
48
46
|
isSearchFieldHidden,
|
|
49
47
|
style
|
|
50
48
|
} = attributes;
|
|
@@ -121,7 +119,7 @@ export default function SearchEdit({
|
|
|
121
119
|
});
|
|
122
120
|
}, [hasOnlyButton, isSelected, setAttributes, width]);
|
|
123
121
|
const getBlockClassNames = () => {
|
|
124
|
-
return classnames(className, isButtonPositionInside ? 'wp-block-search__button-inside' : undefined, isButtonPositionOutside ? 'wp-block-search__button-outside' : undefined, hasNoButton ? 'wp-block-search__no-button' : undefined, hasOnlyButton ? 'wp-block-search__button-only' : undefined, !buttonUseIcon && !hasNoButton ? 'wp-block-search__text-button' : undefined, buttonUseIcon && !hasNoButton ? 'wp-block-search__icon-button' : undefined, hasOnlyButton &&
|
|
122
|
+
return classnames(className, isButtonPositionInside ? 'wp-block-search__button-inside' : undefined, isButtonPositionOutside ? 'wp-block-search__button-outside' : undefined, hasNoButton ? 'wp-block-search__no-button' : undefined, hasOnlyButton ? 'wp-block-search__button-only' : undefined, !buttonUseIcon && !hasNoButton ? 'wp-block-search__text-button' : undefined, buttonUseIcon && !hasNoButton ? 'wp-block-search__icon-button' : undefined, hasOnlyButton && isSearchFieldHidden ? 'wp-block-search__searchfield-hidden' : undefined);
|
|
125
123
|
};
|
|
126
124
|
const buttonPositionControls = [{
|
|
127
125
|
role: 'menuitemradio',
|
|
@@ -227,7 +225,7 @@ export default function SearchEdit({
|
|
|
227
225
|
} : borderProps.style)
|
|
228
226
|
};
|
|
229
227
|
const handleButtonClick = () => {
|
|
230
|
-
if (hasOnlyButton
|
|
228
|
+
if (hasOnlyButton) {
|
|
231
229
|
setAttributes({
|
|
232
230
|
isSearchFieldHidden: !isSearchFieldHidden
|
|
233
231
|
});
|
|
@@ -308,7 +306,7 @@ export default function SearchEdit({
|
|
|
308
306
|
}, [25, 50, 75, 100].map(widthValue => {
|
|
309
307
|
return createElement(Button, {
|
|
310
308
|
key: widthValue,
|
|
311
|
-
|
|
309
|
+
size: "small",
|
|
312
310
|
variant: widthValue === width && widthUnit === '%' ? 'primary' : undefined,
|
|
313
311
|
onClick: () => setAttributes({
|
|
314
312
|
width: widthValue,
|