@wordpress/block-library 9.33.1-next.ff1cebbba.0 → 9.33.2-next.36001005c.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 +1 -1
- package/README.md +1 -1
- package/build/breadcrumbs/block.json +8 -2
- package/build/breadcrumbs/edit.js +113 -12
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/buttons/transforms.js +7 -7
- package/build/buttons/transforms.js.map +2 -2
- package/build/code/transforms.js +19 -15
- package/build/code/transforms.js.map +2 -2
- package/build/heading/index.js +1 -3
- package/build/heading/index.js.map +3 -3
- package/build/heading/transforms.js +22 -20
- package/build/heading/transforms.js.map +2 -2
- package/build/index.js +5 -3
- package/build/index.js.map +2 -2
- package/build/math/block.json +21 -0
- package/build/math/edit.js +132 -0
- package/build/math/edit.js.map +7 -0
- package/build/math/index.js +63 -0
- package/build/math/index.js.map +7 -0
- package/build/math/init.js +35 -0
- package/build/math/init.js.map +7 -0
- package/build/math/save.js +40 -0
- package/build/math/save.js.map +7 -0
- package/build/navigation/edit/menu-inspector-controls.js +2 -2
- package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
- package/build/navigation-link/edit.js +5 -2
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/link-ui/index.js +1 -1
- package/build/navigation-link/link-ui/index.js.map +2 -2
- package/build/navigation-link/shared/controls.js +39 -16
- package/build/navigation-link/shared/controls.js.map +3 -3
- package/build/navigation-link/shared/index.js +2 -0
- package/build/navigation-link/shared/index.js.map +2 -2
- package/build/navigation-link/shared/update-attributes.js +3 -1
- package/build/navigation-link/shared/update-attributes.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +46 -13
- package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build/navigation-submenu/edit.js +5 -2
- package/build/navigation-submenu/edit.js.map +2 -2
- package/build/page-list/use-convert-to-navigation-links.js +6 -1
- package/build/page-list/use-convert-to-navigation-links.js.map +2 -2
- package/build/paragraph/index.js +1 -3
- package/build/paragraph/index.js.map +3 -3
- package/build/post-date/deprecated.js +98 -2
- package/build/post-date/deprecated.js.map +2 -2
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/variations.js +4 -4
- package/build/post-date/variations.js.map +2 -2
- package/build/term-template/block.json +0 -1
- package/build/term-template/edit.js +4 -1
- package/build/term-template/edit.js.map +2 -2
- package/build/terms-query/block.json +0 -1
- package/build/utils/get-transformed-attributes.js +82 -0
- package/build/utils/get-transformed-attributes.js.map +7 -0
- package/build-module/breadcrumbs/block.json +8 -2
- package/build-module/breadcrumbs/edit.js +117 -14
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/buttons/transforms.js +7 -7
- package/build-module/buttons/transforms.js.map +2 -2
- package/build-module/code/transforms.js +19 -15
- package/build-module/code/transforms.js.map +2 -2
- package/build-module/heading/index.js +1 -3
- package/build-module/heading/index.js.map +2 -2
- package/build-module/heading/transforms.js +22 -20
- package/build-module/heading/transforms.js.map +2 -2
- package/build-module/index.js +5 -3
- package/build-module/index.js.map +2 -2
- package/build-module/math/block.json +21 -0
- package/build-module/math/edit.js +110 -0
- package/build-module/math/edit.js.map +7 -0
- package/build-module/math/index.js +26 -0
- package/build-module/math/index.js.map +7 -0
- package/build-module/math/init.js +8 -0
- package/build-module/math/init.js.map +7 -0
- package/build-module/math/save.js +20 -0
- package/build-module/math/save.js.map +7 -0
- package/build-module/navigation/edit/menu-inspector-controls.js +2 -2
- package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
- package/build-module/navigation-link/edit.js +5 -2
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/link-ui/index.js +1 -1
- package/build-module/navigation-link/link-ui/index.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +40 -17
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/index.js +5 -1
- package/build-module/navigation-link/shared/index.js.map +2 -2
- package/build-module/navigation-link/shared/update-attributes.js +3 -1
- package/build-module/navigation-link/shared/update-attributes.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +45 -13
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/navigation-submenu/edit.js +5 -2
- package/build-module/navigation-submenu/edit.js.map +2 -2
- package/build-module/page-list/use-convert-to-navigation-links.js +6 -1
- package/build-module/page-list/use-convert-to-navigation-links.js.map +2 -2
- package/build-module/paragraph/index.js +1 -3
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/post-date/deprecated.js +98 -2
- package/build-module/post-date/deprecated.js.map +2 -2
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/variations.js +4 -4
- package/build-module/post-date/variations.js.map +2 -2
- package/build-module/term-template/block.json +0 -1
- package/build-module/term-template/edit.js +4 -1
- package/build-module/term-template/edit.js.map +2 -2
- package/build-module/terms-query/block.json +0 -1
- package/build-module/utils/get-transformed-attributes.js +58 -0
- package/build-module/utils/get-transformed-attributes.js.map +7 -0
- package/build-style/editor-rtl.css +2 -2
- package/build-style/editor.css +2 -2
- package/build-style/navigation-link/editor-rtl.css +1 -1
- package/build-style/navigation-link/editor.css +1 -1
- package/build-style/video/editor-rtl.css +1 -1
- package/build-style/video/editor.css +1 -1
- package/package.json +61 -36
- package/src/breadcrumbs/block.json +8 -2
- package/src/breadcrumbs/edit.js +163 -18
- package/src/breadcrumbs/index.php +118 -16
- package/src/buttons/transforms.js +6 -6
- package/src/code/transforms.js +16 -14
- package/src/heading/index.js +0 -2
- package/src/heading/transforms.js +25 -24
- package/src/index.js +5 -3
- package/src/math/block.json +21 -0
- package/src/math/edit.js +123 -0
- package/src/math/index.js +31 -0
- package/src/math/init.js +4 -0
- package/src/math/save.js +20 -0
- package/src/navigation/edit/menu-inspector-controls.js +7 -6
- package/src/navigation-link/edit.js +5 -2
- package/src/navigation-link/editor.scss +1 -1
- package/src/navigation-link/index.php +4 -18
- package/src/navigation-link/link-ui/index.js +4 -2
- package/src/navigation-link/shared/controls.js +69 -20
- package/src/navigation-link/shared/index.js +4 -1
- package/src/navigation-link/shared/test/controls.js +14 -9
- package/src/navigation-link/shared/test/update-attributes.test.js +8 -0
- package/src/navigation-link/shared/test/use-entity-binding.js +132 -17
- package/src/navigation-link/shared/update-attributes.js +1 -0
- package/src/navigation-link/shared/use-entity-binding.js +74 -19
- package/src/navigation-submenu/edit.js +5 -2
- package/src/navigation-submenu/index.php +3 -17
- package/src/page-list/test/{convert-to-links-modal.js → convert-to-navigation-links.js} +67 -0
- package/src/page-list/use-convert-to-navigation-links.js +11 -1
- package/src/paragraph/index.js +0 -2
- package/src/post-date/deprecated.js +104 -2
- package/src/post-date/edit.js +1 -1
- package/src/post-date/index.php +3 -3
- package/src/post-date/variations.js +5 -4
- package/src/term-template/block.json +0 -1
- package/src/term-template/edit.js +4 -1
- package/src/term-template/index.php +4 -6
- package/src/terms-query/block.json +0 -1
- package/src/utils/get-transformed-attributes.js +98 -0
- package/src/video/editor.scss +1 -1
- package/tsconfig.json +1 -0
- package/build/heading/variations.js +0 -48
- package/build/heading/variations.js.map +0 -7
- package/build/paragraph/variations.js +0 -48
- package/build/paragraph/variations.js.map +0 -7
- package/build/utils/get-transformed-metadata.js +0 -65
- package/build/utils/get-transformed-metadata.js.map +0 -7
- package/build-module/heading/variations.js +0 -28
- package/build-module/heading/variations.js.map +0 -7
- package/build-module/paragraph/variations.js +0 -28
- package/build-module/paragraph/variations.js.map +0 -7
- package/build-module/utils/get-transformed-metadata.js +0 -41
- package/build-module/utils/get-transformed-metadata.js.map +0 -7
- package/src/heading/variations.js +0 -29
- package/src/paragraph/variations.js +0 -29
- package/src/utils/get-transformed-metadata.js +0 -69
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/term-template/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ToolbarGroup } from '@wordpress/components';\nimport { list, grid } from '@wordpress/icons';\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEntityRecords } from '@wordpress/core-data';\n\nconst TEMPLATE = [ [ 'core/term-name' ] ];\n\nfunction TermTemplateInnerBlocks( { classList } ) {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: clsx( 'wp-block-term', classList ) },\n\t\t{ template: TEMPLATE, __unstableDisableLayoutClassNames: true }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction TermTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tclassList,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: clsx( 'wp-block-term', classList ),\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n// Prevent re-rendering of the block preview when the terms data changes.\nconst MemoizedTermTemplateBlockPreview = memo( TermTemplateBlockPreview );\n\nexport default function TermTemplateEdit( {\n\tclientId,\n\tattributes: { layout },\n\tsetAttributes,\n\tcontext: {\n\t\ttermQuery: {\n\t\t\ttaxonomy,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\thideEmpty,\n\t\t\tshowNested = false,\n\t\t\tperPage,\n\t\t\tinclude,\n\t\t} = {},\n\t},\n\t__unstableLayoutClassNames,\n} ) {\n\tconst { type: layoutType, columnCount = 3 } = layout || {};\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\n\tconst queryArgs = {\n\t\thide_empty: hideEmpty,\n\t\torder,\n\t\torderby: orderBy,\n\t\tper_page: perPage,\n\t};\n\n\t// Nested terms are returned by default from REST API as long as parent is not set.\n\t// If we want to show nested terms, we must not set parent at all.\n\tif ( ! showNested && ! include?.length ) {\n\t\tqueryArgs.parent = 0;\n\t}\n\n\tif ( include?.length ) {\n\t\tqueryArgs.include = include;\n\t\t// If we are using `include` update the `order` and `orderby` arguments to preserve the order.\n\t\tqueryArgs.orderby = 'include';\n\t\tqueryArgs.order = 'asc';\n\t}\n\n\tconst { records: terms } = useEntityRecords(\n\t\t'taxonomy',\n\t\ttaxonomy,\n\t\tqueryArgs\n\t);\n\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst blockProps = useBlockProps( {\n\t\tclassName: __unstableLayoutClassNames,\n\t} );\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tterms?.map( ( term ) => ( {\n\t\t\t\ttaxonomy,\n\t\t\t\ttermId: term.id,\n\t\t\t\tclassList: `term-${ term.id }`,\n\t\t\t\ttermData: term,\n\t\t\t} ) ),\n\t\t[ terms, taxonomy ]\n\t);\n\n\tif ( ! terms ) {\n\t\treturn (\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t<li className=\"wp-block-term term-loading\">\n\t\t\t\t\t<div className=\"term-loading-placeholder\" />\n\t\t\t\t</li>\n\t\t\t</ul>\n\t\t);\n\t}\n\n\tif ( ! terms.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No terms found.' ) }</p>;\n\t}\n\n\tconst setDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( ( prevAttributes ) => ( {\n\t\t\tlayout: { ...prevAttributes.layout, ...newDisplayLayout },\n\t\t} ) );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ticon: list,\n\t\t\t\t\t\t\ttitle: _x(\n\t\t\t\t\t\t\t\t'List view',\n\t\t\t\t\t\t\t\t'Term template block display setting'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tsetDisplayLayout( { type: 'default' } ),\n\t\t\t\t\t\t\tisActive:\n\t\t\t\t\t\t\t\tlayoutType === 'default' ||\n\t\t\t\t\t\t\t\tlayoutType === 'constrained',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ticon: grid,\n\t\t\t\t\t\t\ttitle: _x(\n\t\t\t\t\t\t\t\t'Grid view',\n\t\t\t\t\t\t\t\t'Term template block display setting'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\ttype: 'grid',\n\t\t\t\t\t\t\t\t\tcolumnCount,\n\t\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\tisActive: layoutType === 'grid',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t{ blockContexts?.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.termId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.termId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.termId ) ? (\n\t\t\t\t\t\t\t<TermTemplateInnerBlocks\n\t\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedTermTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.termId }\n\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\tsetActiveBlockContextId={ setActiveBlockContextId }\n\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\tblockContext.termId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.termId )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "AA8BQ,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ToolbarGroup } from '@wordpress/components';\nimport { list, grid } from '@wordpress/icons';\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEntityRecords } from '@wordpress/core-data';\n\nconst TEMPLATE = [ [ 'core/term-name' ] ];\n\nfunction TermTemplateInnerBlocks( { classList } ) {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: clsx( 'wp-block-term', classList ) },\n\t\t{ template: TEMPLATE, __unstableDisableLayoutClassNames: true }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction TermTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tclassList,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: clsx( 'wp-block-term', classList ),\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n// Prevent re-rendering of the block preview when the terms data changes.\nconst MemoizedTermTemplateBlockPreview = memo( TermTemplateBlockPreview );\n\nexport default function TermTemplateEdit( {\n\tclientId,\n\tattributes: { layout },\n\tsetAttributes,\n\tcontext: {\n\t\ttermQuery: {\n\t\t\ttaxonomy,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\thideEmpty,\n\t\t\tshowNested = false,\n\t\t\tperPage,\n\t\t\tinclude,\n\t\t} = {},\n\t},\n\t__unstableLayoutClassNames,\n} ) {\n\tconst { type: layoutType, columnCount = 3 } = layout || {};\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\n\tconst queryArgs = {\n\t\thide_empty: hideEmpty,\n\t\torder,\n\t\torderby: orderBy,\n\t\t// There is a mismatch between `WP_Term_Query` and the REST API parameter default\n\t\t// values to fetch all items. In `WP_Term_Query`, the default is `''|0` and in\n\t\t// the REST API is `-1`.\n\t\tper_page: perPage || -1,\n\t};\n\n\t// Nested terms are returned by default from REST API as long as parent is not set.\n\t// If we want to show nested terms, we must not set parent at all.\n\tif ( ! showNested && ! include?.length ) {\n\t\tqueryArgs.parent = 0;\n\t}\n\n\tif ( include?.length ) {\n\t\tqueryArgs.include = include;\n\t\t// If we are using `include` update the `order` and `orderby` arguments to preserve the order.\n\t\tqueryArgs.orderby = 'include';\n\t\tqueryArgs.order = 'asc';\n\t}\n\n\tconst { records: terms } = useEntityRecords(\n\t\t'taxonomy',\n\t\ttaxonomy,\n\t\tqueryArgs\n\t);\n\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst blockProps = useBlockProps( {\n\t\tclassName: __unstableLayoutClassNames,\n\t} );\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tterms?.map( ( term ) => ( {\n\t\t\t\ttaxonomy,\n\t\t\t\ttermId: term.id,\n\t\t\t\tclassList: `term-${ term.id }`,\n\t\t\t\ttermData: term,\n\t\t\t} ) ),\n\t\t[ terms, taxonomy ]\n\t);\n\n\tif ( ! terms ) {\n\t\treturn (\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t<li className=\"wp-block-term term-loading\">\n\t\t\t\t\t<div className=\"term-loading-placeholder\" />\n\t\t\t\t</li>\n\t\t\t</ul>\n\t\t);\n\t}\n\n\tif ( ! terms.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No terms found.' ) }</p>;\n\t}\n\n\tconst setDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( ( prevAttributes ) => ( {\n\t\t\tlayout: { ...prevAttributes.layout, ...newDisplayLayout },\n\t\t} ) );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ticon: list,\n\t\t\t\t\t\t\ttitle: _x(\n\t\t\t\t\t\t\t\t'List view',\n\t\t\t\t\t\t\t\t'Term template block display setting'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tsetDisplayLayout( { type: 'default' } ),\n\t\t\t\t\t\t\tisActive:\n\t\t\t\t\t\t\t\tlayoutType === 'default' ||\n\t\t\t\t\t\t\t\tlayoutType === 'constrained',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ticon: grid,\n\t\t\t\t\t\t\ttitle: _x(\n\t\t\t\t\t\t\t\t'Grid view',\n\t\t\t\t\t\t\t\t'Term template block display setting'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\ttype: 'grid',\n\t\t\t\t\t\t\t\t\tcolumnCount,\n\t\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\tisActive: layoutType === 'grid',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<ul { ...blockProps }>\n\t\t\t\t{ blockContexts?.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.termId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.termId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.termId ) ? (\n\t\t\t\t\t\t\t<TermTemplateInnerBlocks\n\t\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedTermTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.termId }\n\t\t\t\t\t\t\tclassList={ blockContext.classList }\n\t\t\t\t\t\t\tsetActiveBlockContextId={ setActiveBlockContextId }\n\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\tblockContext.termId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.termId )\n\t\t\t\t\t\t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+
import { getBlockType, hasBlockSupport } from "@wordpress/blocks";
|
|
2
|
+
function getTransformedAttributes(attributes, newBlockName, bindingsCallback = null) {
|
|
3
|
+
if (!attributes) {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
const newBlockType = getBlockType(newBlockName);
|
|
7
|
+
if (!newBlockType) {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
const transformedAttributes = {};
|
|
11
|
+
if (hasBlockSupport(newBlockType, "allowedBlocks") && attributes.allowedBlocks) {
|
|
12
|
+
transformedAttributes.allowedBlocks = attributes.allowedBlocks;
|
|
13
|
+
}
|
|
14
|
+
if (hasBlockSupport(newBlockType, "anchor") && attributes.anchor) {
|
|
15
|
+
transformedAttributes.anchor = attributes.anchor;
|
|
16
|
+
}
|
|
17
|
+
if (hasBlockSupport(newBlockType, "ariaLabel") && attributes.ariaLabel) {
|
|
18
|
+
transformedAttributes.ariaLabel = attributes.ariaLabel;
|
|
19
|
+
}
|
|
20
|
+
if (hasBlockSupport(newBlockType, "className") && attributes.className) {
|
|
21
|
+
transformedAttributes.className = attributes.className;
|
|
22
|
+
}
|
|
23
|
+
if (attributes.metadata) {
|
|
24
|
+
const transformedMetadata = ["noteId"];
|
|
25
|
+
if (bindingsCallback) {
|
|
26
|
+
transformedMetadata.push("id", "bindings");
|
|
27
|
+
}
|
|
28
|
+
if (hasBlockSupport(newBlockType, "renaming", true)) {
|
|
29
|
+
transformedMetadata.push("name");
|
|
30
|
+
}
|
|
31
|
+
if (hasBlockSupport(newBlockType, "blockVisibility", true)) {
|
|
32
|
+
transformedMetadata.push("blockVisibility");
|
|
33
|
+
}
|
|
34
|
+
if (transformedMetadata.length > 0) {
|
|
35
|
+
const newMetadata = Object.entries(attributes.metadata).reduce(
|
|
36
|
+
(obj, [prop, value]) => {
|
|
37
|
+
if (!transformedMetadata.includes(prop)) {
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
obj[prop] = prop === "bindings" ? bindingsCallback(value) : value;
|
|
41
|
+
return obj;
|
|
42
|
+
},
|
|
43
|
+
{}
|
|
44
|
+
);
|
|
45
|
+
if (Object.keys(newMetadata).length > 0) {
|
|
46
|
+
transformedAttributes.metadata = newMetadata;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (Object.keys(transformedAttributes).length === 0) {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
return transformedAttributes;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
getTransformedAttributes
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=get-transformed-attributes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-transformed-attributes.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Transform block support attributes and metadata during block transforms.\n *\n * @param {Object} attributes Original attributes from the block being transformed.\n * @param {string} newBlockName Name of the target block after transformation.\n * @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.\n * @return {Object} New attributes object with preserved block support attributes and metadata.\n */\nexport function getTransformedAttributes(\n\tattributes,\n\tnewBlockName,\n\tbindingsCallback = null\n) {\n\tif ( ! attributes ) {\n\t\treturn undefined;\n\t}\n\n\tconst newBlockType = getBlockType( newBlockName );\n\tif ( ! newBlockType ) {\n\t\treturn undefined;\n\t}\n\n\tconst transformedAttributes = {};\n\n\t// Handle attributes derived from block support.\n\tif (\n\t\thasBlockSupport( newBlockType, 'allowedBlocks' ) &&\n\t\tattributes.allowedBlocks\n\t) {\n\t\ttransformedAttributes.allowedBlocks = attributes.allowedBlocks;\n\t}\n\tif ( hasBlockSupport( newBlockType, 'anchor' ) && attributes.anchor ) {\n\t\ttransformedAttributes.anchor = attributes.anchor;\n\t}\n\tif (\n\t\thasBlockSupport( newBlockType, 'ariaLabel' ) &&\n\t\tattributes.ariaLabel\n\t) {\n\t\ttransformedAttributes.ariaLabel = attributes.ariaLabel;\n\t}\n\tif (\n\t\thasBlockSupport( newBlockType, 'className' ) &&\n\t\tattributes.className\n\t) {\n\t\ttransformedAttributes.className = attributes.className;\n\t}\n\n\t// Handle metadata transformation.\n\tif ( attributes.metadata ) {\n\t\t// The metadata properties that should be preserved after the transform.\n\t\tconst transformedMetadata = [ 'noteId' ];\n\n\t\t// If there is a transform bindings callback, add the `id` and `bindings` properties.\n\t\tif ( bindingsCallback ) {\n\t\t\ttransformedMetadata.push( 'id', 'bindings' );\n\t\t}\n\n\t\t// Handle metadata properties derived from block support.\n\t\tif ( hasBlockSupport( newBlockType, 'renaming', true ) ) {\n\t\t\ttransformedMetadata.push( 'name' );\n\t\t}\n\t\tif ( hasBlockSupport( newBlockType, 'blockVisibility', true ) ) {\n\t\t\ttransformedMetadata.push( 'blockVisibility' );\n\t\t}\n\n\t\t// Only process metadata if there are supported properties.\n\t\tif ( transformedMetadata.length > 0 ) {\n\t\t\tconst newMetadata = Object.entries( attributes.metadata ).reduce(\n\t\t\t\t( obj, [ prop, value ] ) => {\n\t\t\t\t\t// If prop is not supported, don't add it to the new metadata object.\n\t\t\t\t\tif ( ! transformedMetadata.includes( prop ) ) {\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t}\n\t\t\t\t\tobj[ prop ] =\n\t\t\t\t\t\tprop === 'bindings' ? bindingsCallback( value ) : value;\n\t\t\t\t\treturn obj;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\t// Only add metadata if object is not empty.\n\t\t\tif ( Object.keys( newMetadata ).length > 0 ) {\n\t\t\t\ttransformedAttributes.metadata = newMetadata;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( Object.keys( transformedAttributes ).length === 0 ) {\n\t\treturn undefined;\n\t}\n\n\treturn transformedAttributes;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,cAAc,uBAAuB;AAUvC,SA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AAAA,EACD;AAEA,MAAK,OAAO,KAAM,qBAAsB,EAAE,WAAW,GAAI;AACxD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1950,7 +1950,7 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
1950
1950
|
.link-control-transform__subheading {
|
|
1951
1951
|
font-size: 11px;
|
|
1952
1952
|
text-transform: uppercase;
|
|
1953
|
-
font-weight:
|
|
1953
|
+
font-weight: 499;
|
|
1954
1954
|
color: #1e1e1e;
|
|
1955
1955
|
margin-bottom: 1.5em;
|
|
1956
1956
|
}
|
|
@@ -2597,7 +2597,7 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2597
2597
|
color: #757575;
|
|
2598
2598
|
text-transform: uppercase;
|
|
2599
2599
|
font-size: 11px;
|
|
2600
|
-
font-weight:
|
|
2600
|
+
font-weight: 499;
|
|
2601
2601
|
display: block;
|
|
2602
2602
|
}
|
|
2603
2603
|
|
package/build-style/editor.css
CHANGED
|
@@ -1957,7 +1957,7 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
1957
1957
|
.link-control-transform__subheading {
|
|
1958
1958
|
font-size: 11px;
|
|
1959
1959
|
text-transform: uppercase;
|
|
1960
|
-
font-weight:
|
|
1960
|
+
font-weight: 499;
|
|
1961
1961
|
color: #1e1e1e;
|
|
1962
1962
|
margin-bottom: 1.5em;
|
|
1963
1963
|
}
|
|
@@ -2604,7 +2604,7 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2604
2604
|
color: #757575;
|
|
2605
2605
|
text-transform: uppercase;
|
|
2606
2606
|
font-size: 11px;
|
|
2607
|
-
font-weight:
|
|
2607
|
+
font-weight: 499;
|
|
2608
2608
|
display: block;
|
|
2609
2609
|
}
|
|
2610
2610
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.33.
|
|
3
|
+
"version": "9.33.2-next.36001005c.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -51,46 +51,71 @@
|
|
|
51
51
|
"src/*/editor.scss",
|
|
52
52
|
"src/*/theme.scss"
|
|
53
53
|
],
|
|
54
|
+
"wpCopyFiles": {
|
|
55
|
+
"files": [
|
|
56
|
+
"src/**/*.php",
|
|
57
|
+
"src/*/block.json"
|
|
58
|
+
],
|
|
59
|
+
"transforms": {
|
|
60
|
+
"php": {
|
|
61
|
+
"functionPrefix": "gutenberg_",
|
|
62
|
+
"classSuffix": "_Gutenberg",
|
|
63
|
+
"prefixFunctions": [
|
|
64
|
+
"wp_apply_colors_support",
|
|
65
|
+
"wp_enqueue_block_support_styles",
|
|
66
|
+
"wp_get_typography_font_size_value",
|
|
67
|
+
"wp_style_engine_get_styles",
|
|
68
|
+
"wp_get_global_settings"
|
|
69
|
+
],
|
|
70
|
+
"suffixClasses": [
|
|
71
|
+
"WP_Navigation_Block_Renderer"
|
|
72
|
+
],
|
|
73
|
+
"addActionPriority": 20,
|
|
74
|
+
"flattenIndexFiles": true
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
54
78
|
"sideEffects": [
|
|
55
79
|
"build-style/**",
|
|
56
80
|
"src/**/*.scss",
|
|
57
81
|
"{src,build,build-module}/*/init.js"
|
|
58
82
|
],
|
|
59
83
|
"dependencies": {
|
|
60
|
-
"@wordpress/a11y": "^4.
|
|
61
|
-
"@wordpress/api-fetch": "^7.
|
|
62
|
-
"@wordpress/autop": "^4.
|
|
63
|
-
"@wordpress/base-styles": "^6.
|
|
64
|
-
"@wordpress/blob": "^4.
|
|
65
|
-
"@wordpress/block-editor": "^15.
|
|
66
|
-
"@wordpress/blocks": "^15.
|
|
67
|
-
"@wordpress/components": "^30.
|
|
68
|
-
"@wordpress/compose": "^7.
|
|
69
|
-
"@wordpress/core-data": "^7.
|
|
70
|
-
"@wordpress/data": "^10.
|
|
71
|
-
"@wordpress/date": "^5.
|
|
72
|
-
"@wordpress/deprecated": "^4.
|
|
73
|
-
"@wordpress/dom": "^4.
|
|
74
|
-
"@wordpress/element": "^6.
|
|
75
|
-
"@wordpress/escape-html": "^3.
|
|
76
|
-
"@wordpress/hooks": "^4.
|
|
77
|
-
"@wordpress/html-entities": "^4.
|
|
78
|
-
"@wordpress/i18n": "^6.
|
|
79
|
-
"@wordpress/icons": "^11.0.1-next.
|
|
80
|
-
"@wordpress/interactivity": "^6.33.1-next.
|
|
81
|
-
"@wordpress/interactivity-router": "^2.
|
|
82
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
83
|
-
"@wordpress/keycodes": "^4.
|
|
84
|
-
"@wordpress/
|
|
85
|
-
"@wordpress/
|
|
86
|
-
"@wordpress/
|
|
87
|
-
"@wordpress/
|
|
88
|
-
"@wordpress/
|
|
89
|
-
"@wordpress/
|
|
90
|
-
"@wordpress/
|
|
91
|
-
"@wordpress/
|
|
92
|
-
"@wordpress/
|
|
93
|
-
"@wordpress/
|
|
84
|
+
"@wordpress/a11y": "^4.33.1-next.36001005c.0",
|
|
85
|
+
"@wordpress/api-fetch": "^7.33.1-next.36001005c.0",
|
|
86
|
+
"@wordpress/autop": "^4.33.1-next.36001005c.0",
|
|
87
|
+
"@wordpress/base-styles": "^6.10.1-next.36001005c.0",
|
|
88
|
+
"@wordpress/blob": "^4.33.1-next.36001005c.0",
|
|
89
|
+
"@wordpress/block-editor": "^15.6.1-next.36001005c.0",
|
|
90
|
+
"@wordpress/blocks": "^15.6.1-next.36001005c.0",
|
|
91
|
+
"@wordpress/components": "^30.7.1-next.36001005c.0",
|
|
92
|
+
"@wordpress/compose": "^7.33.1-next.36001005c.0",
|
|
93
|
+
"@wordpress/core-data": "^7.33.1-next.36001005c.0",
|
|
94
|
+
"@wordpress/data": "^10.33.1-next.36001005c.0",
|
|
95
|
+
"@wordpress/date": "^5.33.1-next.36001005c.0",
|
|
96
|
+
"@wordpress/deprecated": "^4.33.1-next.36001005c.0",
|
|
97
|
+
"@wordpress/dom": "^4.33.1-next.36001005c.0",
|
|
98
|
+
"@wordpress/element": "^6.33.1-next.36001005c.0",
|
|
99
|
+
"@wordpress/escape-html": "^3.33.1-next.36001005c.0",
|
|
100
|
+
"@wordpress/hooks": "^4.33.1-next.36001005c.0",
|
|
101
|
+
"@wordpress/html-entities": "^4.33.1-next.36001005c.0",
|
|
102
|
+
"@wordpress/i18n": "^6.6.1-next.36001005c.0",
|
|
103
|
+
"@wordpress/icons": "^11.0.1-next.36001005c.0",
|
|
104
|
+
"@wordpress/interactivity": "^6.33.1-next.36001005c.0",
|
|
105
|
+
"@wordpress/interactivity-router": "^2.33.1-next.36001005c.0",
|
|
106
|
+
"@wordpress/keyboard-shortcuts": "^5.33.1-next.36001005c.0",
|
|
107
|
+
"@wordpress/keycodes": "^4.33.1-next.36001005c.0",
|
|
108
|
+
"@wordpress/latex-to-mathml": "^1.1.1-next.36001005c.0",
|
|
109
|
+
"@wordpress/notices": "^5.33.1-next.36001005c.0",
|
|
110
|
+
"@wordpress/patterns": "^2.33.1-next.36001005c.0",
|
|
111
|
+
"@wordpress/primitives": "^4.33.1-next.36001005c.0",
|
|
112
|
+
"@wordpress/private-apis": "^1.33.1-next.36001005c.0",
|
|
113
|
+
"@wordpress/reusable-blocks": "^5.33.1-next.36001005c.0",
|
|
114
|
+
"@wordpress/rich-text": "^7.33.1-next.36001005c.0",
|
|
115
|
+
"@wordpress/server-side-render": "^6.9.1-next.36001005c.0",
|
|
116
|
+
"@wordpress/url": "^4.33.1-next.36001005c.0",
|
|
117
|
+
"@wordpress/viewport": "^6.33.1-next.36001005c.0",
|
|
118
|
+
"@wordpress/wordcount": "^4.33.1-next.36001005c.0",
|
|
94
119
|
"change-case": "^4.1.2",
|
|
95
120
|
"clsx": "^2.1.1",
|
|
96
121
|
"colord": "^2.7.0",
|
|
@@ -108,5 +133,5 @@
|
|
|
108
133
|
"publishConfig": {
|
|
109
134
|
"access": "public"
|
|
110
135
|
},
|
|
111
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "b73a8a22e779c59efb8f911e32b681652f237d60"
|
|
112
137
|
}
|
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
"apiVersion": 3,
|
|
4
4
|
"name": "core/breadcrumbs",
|
|
5
5
|
"title": "Breadcrumbs",
|
|
6
|
+
"__experimental": true,
|
|
6
7
|
"category": "theme",
|
|
7
|
-
"description": "Display a breadcrumb trail
|
|
8
|
+
"description": "Display a breadcrumb trail for hierarchical post types or based on taxonomy terms.",
|
|
8
9
|
"textdomain": "default",
|
|
9
10
|
"attributes": {
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "auto",
|
|
14
|
+
"enum": [ "auto", "postWithTerms", "postWithAncestors" ]
|
|
15
|
+
},
|
|
10
16
|
"separator": {
|
|
11
17
|
"type": "string",
|
|
12
18
|
"default": "/"
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
"default": true
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
|
-
"usesContext": [ "postId", "postType" ],
|
|
25
|
+
"usesContext": [ "postId", "postType", "templateSlug" ],
|
|
20
26
|
"supports": {
|
|
21
27
|
"html": false,
|
|
22
28
|
"spacing": {
|
package/src/breadcrumbs/edit.js
CHANGED
|
@@ -6,52 +6,157 @@ import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
|
|
6
6
|
import {
|
|
7
7
|
ToggleControl,
|
|
8
8
|
TextControl,
|
|
9
|
+
SelectControl,
|
|
9
10
|
__experimentalToolsPanel as ToolsPanel,
|
|
10
11
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
12
|
+
Spinner,
|
|
11
13
|
} from '@wordpress/components';
|
|
12
14
|
import { useSelect } from '@wordpress/data';
|
|
13
15
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
|
-
import { RawHTML } from '@wordpress/element';
|
|
16
|
+
import { useEffect, useState, RawHTML } from '@wordpress/element';
|
|
15
17
|
import { useServerSideRender } from '@wordpress/server-side-render';
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Internal dependencies
|
|
19
21
|
*/
|
|
20
22
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
23
|
+
|
|
21
24
|
const separatorDefaultValue = '/';
|
|
25
|
+
const typeDefaultValue = 'auto';
|
|
26
|
+
|
|
27
|
+
const BREADCRUMB_TYPES = {
|
|
28
|
+
auto: {
|
|
29
|
+
help: __(
|
|
30
|
+
'Try to automatically determine the best type of breadcrumb for the template.'
|
|
31
|
+
),
|
|
32
|
+
},
|
|
33
|
+
postWithAncestors: {
|
|
34
|
+
help: __(
|
|
35
|
+
'Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types.'
|
|
36
|
+
),
|
|
37
|
+
placeholderItems: [ __( 'Ancestor' ), __( 'Parent' ) ],
|
|
38
|
+
},
|
|
39
|
+
postWithTerms: {
|
|
40
|
+
help: __(
|
|
41
|
+
'Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical.'
|
|
42
|
+
),
|
|
43
|
+
placeholderItems: [ __( 'Category' ) ],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
22
46
|
|
|
23
47
|
export default function BreadcrumbEdit( {
|
|
24
48
|
attributes,
|
|
25
49
|
setAttributes,
|
|
26
|
-
context: { postId, postType },
|
|
50
|
+
context: { postId, postType, templateSlug },
|
|
27
51
|
} ) {
|
|
28
|
-
const { separator, showHomeLink } = attributes;
|
|
29
|
-
const isPostTypeHierarchical =
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
const { separator, showHomeLink, type } = attributes;
|
|
53
|
+
const { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } =
|
|
54
|
+
useSelect(
|
|
55
|
+
( select ) => {
|
|
56
|
+
if ( ! postType ) {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
const _post = select( coreStore ).getEntityRecord(
|
|
60
|
+
'postType',
|
|
61
|
+
postType,
|
|
62
|
+
postId
|
|
63
|
+
);
|
|
64
|
+
const postTypeObject =
|
|
65
|
+
select( coreStore ).getPostType( postType );
|
|
66
|
+
const postTypeHasTaxonomies =
|
|
67
|
+
postTypeObject && postTypeObject.taxonomies.length;
|
|
68
|
+
let taxonomies;
|
|
69
|
+
if ( postTypeHasTaxonomies ) {
|
|
70
|
+
taxonomies = select( coreStore ).getTaxonomies( {
|
|
71
|
+
type: postType,
|
|
72
|
+
per_page: -1,
|
|
73
|
+
} );
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
post: _post,
|
|
77
|
+
isPostTypeHierarchical: postTypeObject?.hierarchical,
|
|
78
|
+
hasTermsAssigned:
|
|
79
|
+
_post &&
|
|
80
|
+
( taxonomies || [] )
|
|
81
|
+
.filter(
|
|
82
|
+
( { visibility } ) =>
|
|
83
|
+
visibility?.publicly_queryable
|
|
84
|
+
)
|
|
85
|
+
.some( ( taxonomy ) => {
|
|
86
|
+
return !! _post[ taxonomy.rest_base ]?.length;
|
|
87
|
+
} ),
|
|
88
|
+
isLoading:
|
|
89
|
+
! _post ||
|
|
90
|
+
! postTypeObject ||
|
|
91
|
+
( postTypeHasTaxonomies && ! taxonomies ),
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
[ postType, postId ]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// Counter used to cache-bust `useServerSideRender`
|
|
98
|
+
//
|
|
99
|
+
// This is a catch-all signal to re-render the block when a post's title,
|
|
100
|
+
// parent ID, or terms change.
|
|
101
|
+
//
|
|
102
|
+
// This is fundamentally imperfect, because there are other entities which
|
|
103
|
+
// could change in the meantime (the titles of ancestor posts, or the
|
|
104
|
+
// labels of taxonomy terms), hence the choice to re-render systematically
|
|
105
|
+
// upon saving.
|
|
106
|
+
const [ invalidationKey, setInvalidationKey ] = useState( 0 );
|
|
107
|
+
useEffect( () => {
|
|
108
|
+
setInvalidationKey( ( c ) => c + 1 );
|
|
109
|
+
}, [ post ] );
|
|
110
|
+
|
|
38
111
|
const blockProps = useBlockProps();
|
|
39
112
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
40
113
|
const { content } = useServerSideRender( {
|
|
41
114
|
attributes,
|
|
42
115
|
skipBlockSupportAttributes: true,
|
|
43
116
|
block: 'core/breadcrumbs',
|
|
44
|
-
urlQueryArgs: { post_id: postId },
|
|
117
|
+
urlQueryArgs: { post_id: postId, invalidationKey },
|
|
45
118
|
} );
|
|
119
|
+
|
|
120
|
+
if ( isLoading ) {
|
|
121
|
+
return (
|
|
122
|
+
<div { ...blockProps }>
|
|
123
|
+
<Spinner />
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
// TODO: this should be handled better when we add more types.
|
|
128
|
+
let breadcrumbsType;
|
|
129
|
+
const isSpecificSupportedTypeSet = [
|
|
130
|
+
'postWithAncestors',
|
|
131
|
+
'postWithTerms',
|
|
132
|
+
].includes( type );
|
|
133
|
+
if ( isSpecificSupportedTypeSet ) {
|
|
134
|
+
breadcrumbsType = type;
|
|
135
|
+
} else {
|
|
136
|
+
breadcrumbsType = isPostTypeHierarchical
|
|
137
|
+
? 'postWithAncestors'
|
|
138
|
+
: 'postWithTerms';
|
|
139
|
+
}
|
|
46
140
|
let placeholder = null;
|
|
47
|
-
// If no post context or the post type is not hierarchical, show placeholder.
|
|
48
141
|
// This is fragile because this block is server side rendered and we'll have to
|
|
49
142
|
// update the placeholder html if the server side rendering output changes.
|
|
50
|
-
|
|
143
|
+
const showPlaceholder =
|
|
144
|
+
! postId ||
|
|
145
|
+
! postType ||
|
|
146
|
+
// When `templateSlug` is set only show placeholder if the post type is not.
|
|
147
|
+
// This is needed because when we are showing the template in post editor we
|
|
148
|
+
// want to show the real breadcrumbs if we have the post type.
|
|
149
|
+
( templateSlug && ! postType ) ||
|
|
150
|
+
( breadcrumbsType === 'postWithAncestors' &&
|
|
151
|
+
! isPostTypeHierarchical ) ||
|
|
152
|
+
( breadcrumbsType === 'postWithTerms' && ! hasTermsAssigned );
|
|
153
|
+
if ( showPlaceholder ) {
|
|
51
154
|
const placeholderItems = [
|
|
52
155
|
showHomeLink && __( 'Home' ),
|
|
53
|
-
|
|
54
|
-
|
|
156
|
+
// For now if we are adding this in a template show a generic placeholder.
|
|
157
|
+
...( templateSlug && ! isSpecificSupportedTypeSet
|
|
158
|
+
? [ __( 'Page' ) ]
|
|
159
|
+
: BREADCRUMB_TYPES[ breadcrumbsType ].placeholderItems ),
|
|
55
160
|
].filter( Boolean );
|
|
56
161
|
placeholder = (
|
|
57
162
|
<nav
|
|
@@ -84,10 +189,46 @@ export default function BreadcrumbEdit( {
|
|
|
84
189
|
setAttributes( {
|
|
85
190
|
separator: separatorDefaultValue,
|
|
86
191
|
showHomeLink: true,
|
|
192
|
+
type: typeDefaultValue,
|
|
87
193
|
} );
|
|
88
194
|
} }
|
|
89
195
|
dropdownMenuProps={ dropdownMenuProps }
|
|
90
196
|
>
|
|
197
|
+
<ToolsPanelItem
|
|
198
|
+
label={ __( 'Type' ) }
|
|
199
|
+
isShownByDefault
|
|
200
|
+
hasValue={ () => type !== typeDefaultValue }
|
|
201
|
+
onDeselect={ () =>
|
|
202
|
+
setAttributes( {
|
|
203
|
+
type: typeDefaultValue,
|
|
204
|
+
} )
|
|
205
|
+
}
|
|
206
|
+
>
|
|
207
|
+
<SelectControl
|
|
208
|
+
__nextHasNoMarginBottom
|
|
209
|
+
__next40pxDefaultSize
|
|
210
|
+
label={ __( 'Type' ) }
|
|
211
|
+
value={ type }
|
|
212
|
+
onChange={ ( value ) =>
|
|
213
|
+
setAttributes( { type: value } )
|
|
214
|
+
}
|
|
215
|
+
options={ [
|
|
216
|
+
{
|
|
217
|
+
label: __( 'Auto' ),
|
|
218
|
+
value: 'auto',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
label: __( 'Post with ancestors' ),
|
|
222
|
+
value: 'postWithAncestors',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
label: __( 'Post with terms' ),
|
|
226
|
+
value: 'postWithTerms',
|
|
227
|
+
},
|
|
228
|
+
] }
|
|
229
|
+
help={ BREADCRUMB_TYPES[ type ].help }
|
|
230
|
+
/>
|
|
231
|
+
</ToolsPanelItem>
|
|
91
232
|
<ToolsPanelItem
|
|
92
233
|
label={ __( 'Show home link' ) }
|
|
93
234
|
isShownByDefault
|
|
@@ -138,7 +279,11 @@ export default function BreadcrumbEdit( {
|
|
|
138
279
|
</ToolsPanel>
|
|
139
280
|
</InspectorControls>
|
|
140
281
|
<div { ...blockProps }>
|
|
141
|
-
{
|
|
282
|
+
{ showPlaceholder ? (
|
|
283
|
+
placeholder
|
|
284
|
+
) : (
|
|
285
|
+
<RawHTML inert="true">{ content }</RawHTML>
|
|
286
|
+
) }
|
|
142
287
|
</div>
|
|
143
288
|
</>
|
|
144
289
|
);
|