@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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BQ;AA3BR,kBAAiB;AAKjB,wBAA6B;AAC7B,mBAA2B;AAC3B,qBAAwC;AACxC,kBAA0B;AAC1B,kBAAuB;AACvB,0BAOO;AACP,uBAAiC;AAEjC,MAAM,WAAW,CAAE,CAAE,gBAAiB,CAAE;AAExC,SAAS,wBAAyB,EAAE,UAAU,GAAI;AACjD,QAAM,uBAAmB;AAAA,IACxB,EAAE,eAAW,YAAAA,SAAM,iBAAiB,SAAU,EAAE;AAAA,IAChD,EAAE,UAAU,UAAU,mCAAmC,KAAK;AAAA,EAC/D;AACA,SAAO,4CAAC,QAAK,GAAG,kBAAmB;AACpC;AAEA,SAAS,yBAA0B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,wBAAoB,oBAAAC,+BAAiB;AAAA,IAC1C;AAAA,IACA,OAAO;AAAA,MACN,eAAW,YAAAD,SAAM,iBAAiB,SAAU;AAAA,IAC7C;AAAA,EACD,CAAE;AAEF,QAAM,gBAAgB,MAAM;AAC3B,4BAAyB,cAAe;AAAA,EACzC;AAEA,QAAM,QAAQ;AAAA,IACb,SAAS,WAAW,SAAS;AAAA,EAC9B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,UAAW;AAAA,MAEX,MAAK;AAAA,MACL,SAAU;AAAA,MACV,YAAa;AAAA,MACb;AAAA;AAAA,EACD;AAEF;AAGA,MAAM,uCAAmC,qBAAM,wBAAyB;AAEzD,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA,YAAY,EAAE,OAAO;AAAA,EACrB;AAAA,EACA,SAAS;AAAA,IACR,WAAW;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,IACD,IAAI,CAAC;AAAA,EACN;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,MAAM,YAAY,cAAc,EAAE,IAAI,UAAU,CAAC;AACzD,QAAM,CAAE,sBAAsB,uBAAwB,QAAI,yBAAS;AAEnE,QAAM,YAAY;AAAA,IACjB,YAAY;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,
|
|
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\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BQ;AA3BR,kBAAiB;AAKjB,wBAA6B;AAC7B,mBAA2B;AAC3B,qBAAwC;AACxC,kBAA0B;AAC1B,kBAAuB;AACvB,0BAOO;AACP,uBAAiC;AAEjC,MAAM,WAAW,CAAE,CAAE,gBAAiB,CAAE;AAExC,SAAS,wBAAyB,EAAE,UAAU,GAAI;AACjD,QAAM,uBAAmB;AAAA,IACxB,EAAE,eAAW,YAAAA,SAAM,iBAAiB,SAAU,EAAE;AAAA,IAChD,EAAE,UAAU,UAAU,mCAAmC,KAAK;AAAA,EAC/D;AACA,SAAO,4CAAC,QAAK,GAAG,kBAAmB;AACpC;AAEA,SAAS,yBAA0B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,wBAAoB,oBAAAC,+BAAiB;AAAA,IAC1C;AAAA,IACA,OAAO;AAAA,MACN,eAAW,YAAAD,SAAM,iBAAiB,SAAU;AAAA,IAC7C;AAAA,EACD,CAAE;AAEF,QAAM,gBAAgB,MAAM;AAC3B,4BAAyB,cAAe;AAAA,EACzC;AAEA,QAAM,QAAQ;AAAA,IACb,SAAS,WAAW,SAAS;AAAA,EAC9B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,UAAW;AAAA,MAEX,MAAK;AAAA,MACL,SAAU;AAAA,MACV,YAAa;AAAA,MACb;AAA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pB,CACC,GACH;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["clsx", "useBlockPreview", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_transformed_attributes_exports = {};
|
|
20
|
+
__export(get_transformed_attributes_exports, {
|
|
21
|
+
getTransformedAttributes: () => getTransformedAttributes
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_transformed_attributes_exports);
|
|
24
|
+
var import_blocks = require("@wordpress/blocks");
|
|
25
|
+
function getTransformedAttributes(attributes, newBlockName, bindingsCallback = null) {
|
|
26
|
+
if (!attributes) {
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
const newBlockType = (0, import_blocks.getBlockType)(newBlockName);
|
|
30
|
+
if (!newBlockType) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
const transformedAttributes = {};
|
|
34
|
+
if ((0, import_blocks.hasBlockSupport)(newBlockType, "allowedBlocks") && attributes.allowedBlocks) {
|
|
35
|
+
transformedAttributes.allowedBlocks = attributes.allowedBlocks;
|
|
36
|
+
}
|
|
37
|
+
if ((0, import_blocks.hasBlockSupport)(newBlockType, "anchor") && attributes.anchor) {
|
|
38
|
+
transformedAttributes.anchor = attributes.anchor;
|
|
39
|
+
}
|
|
40
|
+
if ((0, import_blocks.hasBlockSupport)(newBlockType, "ariaLabel") && attributes.ariaLabel) {
|
|
41
|
+
transformedAttributes.ariaLabel = attributes.ariaLabel;
|
|
42
|
+
}
|
|
43
|
+
if ((0, import_blocks.hasBlockSupport)(newBlockType, "className") && attributes.className) {
|
|
44
|
+
transformedAttributes.className = attributes.className;
|
|
45
|
+
}
|
|
46
|
+
if (attributes.metadata) {
|
|
47
|
+
const transformedMetadata = ["noteId"];
|
|
48
|
+
if (bindingsCallback) {
|
|
49
|
+
transformedMetadata.push("id", "bindings");
|
|
50
|
+
}
|
|
51
|
+
if ((0, import_blocks.hasBlockSupport)(newBlockType, "renaming", true)) {
|
|
52
|
+
transformedMetadata.push("name");
|
|
53
|
+
}
|
|
54
|
+
if ((0, import_blocks.hasBlockSupport)(newBlockType, "blockVisibility", true)) {
|
|
55
|
+
transformedMetadata.push("blockVisibility");
|
|
56
|
+
}
|
|
57
|
+
if (transformedMetadata.length > 0) {
|
|
58
|
+
const newMetadata = Object.entries(attributes.metadata).reduce(
|
|
59
|
+
(obj, [prop, value]) => {
|
|
60
|
+
if (!transformedMetadata.includes(prop)) {
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
obj[prop] = prop === "bindings" ? bindingsCallback(value) : value;
|
|
64
|
+
return obj;
|
|
65
|
+
},
|
|
66
|
+
{}
|
|
67
|
+
);
|
|
68
|
+
if (Object.keys(newMetadata).length > 0) {
|
|
69
|
+
transformedAttributes.metadata = newMetadata;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (Object.keys(transformedAttributes).length === 0) {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
return transformedAttributes;
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
getTransformedAttributes
|
|
81
|
+
});
|
|
82
|
+
//# 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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA8C;AAUvC,SAAS,yBACf,YACA,cACA,mBAAmB,MAClB;AACD,MAAK,CAAE,YAAa;AACnB,WAAO;AAAA,EACR;AAEA,QAAM,mBAAe,4BAAc,YAAa;AAChD,MAAK,CAAE,cAAe;AACrB,WAAO;AA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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": {
|
|
@@ -4,44 +4,110 @@ import { InspectorControls, useBlockProps } from "@wordpress/block-editor";
|
|
|
4
4
|
import {
|
|
5
5
|
ToggleControl,
|
|
6
6
|
TextControl,
|
|
7
|
+
SelectControl,
|
|
7
8
|
__experimentalToolsPanel as ToolsPanel,
|
|
8
|
-
__experimentalToolsPanelItem as ToolsPanelItem
|
|
9
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
10
|
+
Spinner
|
|
9
11
|
} from "@wordpress/components";
|
|
10
12
|
import { useSelect } from "@wordpress/data";
|
|
11
13
|
import { store as coreStore } from "@wordpress/core-data";
|
|
12
|
-
import { RawHTML } from "@wordpress/element";
|
|
14
|
+
import { useEffect, useState, RawHTML } from "@wordpress/element";
|
|
13
15
|
import { useServerSideRender } from "@wordpress/server-side-render";
|
|
14
16
|
import { useToolsPanelDropdownMenuProps } from "../utils/hooks";
|
|
15
17
|
const separatorDefaultValue = "/";
|
|
18
|
+
const typeDefaultValue = "auto";
|
|
19
|
+
const BREADCRUMB_TYPES = {
|
|
20
|
+
auto: {
|
|
21
|
+
help: __(
|
|
22
|
+
"Try to automatically determine the best type of breadcrumb for the template."
|
|
23
|
+
)
|
|
24
|
+
},
|
|
25
|
+
postWithAncestors: {
|
|
26
|
+
help: __(
|
|
27
|
+
"Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types."
|
|
28
|
+
),
|
|
29
|
+
placeholderItems: [__("Ancestor"), __("Parent")]
|
|
30
|
+
},
|
|
31
|
+
postWithTerms: {
|
|
32
|
+
help: __(
|
|
33
|
+
"Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical."
|
|
34
|
+
),
|
|
35
|
+
placeholderItems: [__("Category")]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
16
38
|
function BreadcrumbEdit({
|
|
17
39
|
attributes,
|
|
18
40
|
setAttributes,
|
|
19
|
-
context: { postId, postType }
|
|
41
|
+
context: { postId, postType, templateSlug }
|
|
20
42
|
}) {
|
|
21
|
-
const { separator, showHomeLink } = attributes;
|
|
22
|
-
const isPostTypeHierarchical = useSelect(
|
|
43
|
+
const { separator, showHomeLink, type } = attributes;
|
|
44
|
+
const { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } = useSelect(
|
|
23
45
|
(select) => {
|
|
24
46
|
if (!postType) {
|
|
25
|
-
return
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
const _post = select(coreStore).getEntityRecord(
|
|
50
|
+
"postType",
|
|
51
|
+
postType,
|
|
52
|
+
postId
|
|
53
|
+
);
|
|
54
|
+
const postTypeObject = select(coreStore).getPostType(postType);
|
|
55
|
+
const postTypeHasTaxonomies = postTypeObject && postTypeObject.taxonomies.length;
|
|
56
|
+
let taxonomies;
|
|
57
|
+
if (postTypeHasTaxonomies) {
|
|
58
|
+
taxonomies = select(coreStore).getTaxonomies({
|
|
59
|
+
type: postType,
|
|
60
|
+
per_page: -1
|
|
61
|
+
});
|
|
26
62
|
}
|
|
27
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
post: _post,
|
|
65
|
+
isPostTypeHierarchical: postTypeObject?.hierarchical,
|
|
66
|
+
hasTermsAssigned: _post && (taxonomies || []).filter(
|
|
67
|
+
({ visibility }) => visibility?.publicly_queryable
|
|
68
|
+
).some((taxonomy) => {
|
|
69
|
+
return !!_post[taxonomy.rest_base]?.length;
|
|
70
|
+
}),
|
|
71
|
+
isLoading: !_post || !postTypeObject || postTypeHasTaxonomies && !taxonomies
|
|
72
|
+
};
|
|
28
73
|
},
|
|
29
|
-
[postType]
|
|
74
|
+
[postType, postId]
|
|
30
75
|
);
|
|
76
|
+
const [invalidationKey, setInvalidationKey] = useState(0);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setInvalidationKey((c) => c + 1);
|
|
79
|
+
}, [post]);
|
|
31
80
|
const blockProps = useBlockProps();
|
|
32
81
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
33
82
|
const { content } = useServerSideRender({
|
|
34
83
|
attributes,
|
|
35
84
|
skipBlockSupportAttributes: true,
|
|
36
85
|
block: "core/breadcrumbs",
|
|
37
|
-
urlQueryArgs: { post_id: postId }
|
|
86
|
+
urlQueryArgs: { post_id: postId, invalidationKey }
|
|
38
87
|
});
|
|
88
|
+
if (isLoading) {
|
|
89
|
+
return /* @__PURE__ */ jsx("div", { ...blockProps, children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
90
|
+
}
|
|
91
|
+
let breadcrumbsType;
|
|
92
|
+
const isSpecificSupportedTypeSet = [
|
|
93
|
+
"postWithAncestors",
|
|
94
|
+
"postWithTerms"
|
|
95
|
+
].includes(type);
|
|
96
|
+
if (isSpecificSupportedTypeSet) {
|
|
97
|
+
breadcrumbsType = type;
|
|
98
|
+
} else {
|
|
99
|
+
breadcrumbsType = isPostTypeHierarchical ? "postWithAncestors" : "postWithTerms";
|
|
100
|
+
}
|
|
39
101
|
let placeholder = null;
|
|
40
|
-
|
|
102
|
+
const showPlaceholder = !postId || !postType || // When `templateSlug` is set only show placeholder if the post type is not.
|
|
103
|
+
// This is needed because when we are showing the template in post editor we
|
|
104
|
+
// want to show the real breadcrumbs if we have the post type.
|
|
105
|
+
templateSlug && !postType || breadcrumbsType === "postWithAncestors" && !isPostTypeHierarchical || breadcrumbsType === "postWithTerms" && !hasTermsAssigned;
|
|
106
|
+
if (showPlaceholder) {
|
|
41
107
|
const placeholderItems = [
|
|
42
108
|
showHomeLink && __("Home"),
|
|
43
|
-
|
|
44
|
-
__("
|
|
109
|
+
// For now if we are adding this in a template show a generic placeholder.
|
|
110
|
+
...templateSlug && !isSpecificSupportedTypeSet ? [__("Page")] : BREADCRUMB_TYPES[breadcrumbsType].placeholderItems
|
|
45
111
|
].filter(Boolean);
|
|
46
112
|
placeholder = /* @__PURE__ */ jsx(
|
|
47
113
|
"nav",
|
|
@@ -65,11 +131,48 @@ function BreadcrumbEdit({
|
|
|
65
131
|
resetAll: () => {
|
|
66
132
|
setAttributes({
|
|
67
133
|
separator: separatorDefaultValue,
|
|
68
|
-
showHomeLink: true
|
|
134
|
+
showHomeLink: true,
|
|
135
|
+
type: typeDefaultValue
|
|
69
136
|
});
|
|
70
137
|
},
|
|
71
138
|
dropdownMenuProps,
|
|
72
139
|
children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
ToolsPanelItem,
|
|
142
|
+
{
|
|
143
|
+
label: __("Type"),
|
|
144
|
+
isShownByDefault: true,
|
|
145
|
+
hasValue: () => type !== typeDefaultValue,
|
|
146
|
+
onDeselect: () => setAttributes({
|
|
147
|
+
type: typeDefaultValue
|
|
148
|
+
}),
|
|
149
|
+
children: /* @__PURE__ */ jsx(
|
|
150
|
+
SelectControl,
|
|
151
|
+
{
|
|
152
|
+
__nextHasNoMarginBottom: true,
|
|
153
|
+
__next40pxDefaultSize: true,
|
|
154
|
+
label: __("Type"),
|
|
155
|
+
value: type,
|
|
156
|
+
onChange: (value) => setAttributes({ type: value }),
|
|
157
|
+
options: [
|
|
158
|
+
{
|
|
159
|
+
label: __("Auto"),
|
|
160
|
+
value: "auto"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
label: __("Post with ancestors"),
|
|
164
|
+
value: "postWithAncestors"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: __("Post with terms"),
|
|
168
|
+
value: "postWithTerms"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
help: BREADCRUMB_TYPES[type].help
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
),
|
|
73
176
|
/* @__PURE__ */ jsx(
|
|
74
177
|
ToolsPanelItem,
|
|
75
178
|
{
|
|
@@ -122,7 +225,7 @@ function BreadcrumbEdit({
|
|
|
122
225
|
]
|
|
123
226
|
}
|
|
124
227
|
) }),
|
|
125
|
-
/* @__PURE__ */ jsx("div", { ...blockProps, children: placeholder
|
|
228
|
+
/* @__PURE__ */ jsx("div", { ...blockProps, children: showPlaceholder ? placeholder : /* @__PURE__ */ jsx(RawHTML, { inert: "true", children: content }) })
|
|
126
229
|
] });
|
|
127
230
|
}
|
|
128
231
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/breadcrumbs/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { RawHTML } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nconst separatorDefaultValue = '/';\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType },\n} ) {\n\tconst { separator, showHomeLink } = attributes;\n\tconst isPostTypeHierarchical
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState, RawHTML } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst separatorDefaultValue = '/';\nconst typeDefaultValue = 'auto';\n\nconst BREADCRUMB_TYPES = {\n\tauto: {\n\t\thelp: __(\n\t\t\t'Try to automatically determine the best type of breadcrumb for the template.'\n\t\t),\n\t},\n\tpostWithAncestors: {\n\t\thelp: __(\n\t\t\t'Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types.'\n\t\t),\n\t\tplaceholderItems: [ __( 'Ancestor' ), __( 'Parent' ) ],\n\t},\n\tpostWithTerms: {\n\t\thelp: __(\n\t\t\t'Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical.'\n\t\t),\n\t\tplaceholderItems: [ __( 'Category' ) ],\n\t},\n};\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType, templateSlug },\n} ) {\n\tconst { separator, showHomeLink, type } = attributes;\n\tconst { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! postType ) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\t\t\t\tconst _post = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t);\n\t\t\t\tconst postTypeObject =\n\t\t\t\t\tselect( coreStore ).getPostType( postType );\n\t\t\t\tconst postTypeHasTaxonomies =\n\t\t\t\t\tpostTypeObject && postTypeObject.taxonomies.length;\n\t\t\t\tlet taxonomies;\n\t\t\t\tif ( postTypeHasTaxonomies ) {\n\t\t\t\t\ttaxonomies = select( coreStore ).getTaxonomies( {\n\t\t\t\t\t\ttype: postType,\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tpost: _post,\n\t\t\t\t\tisPostTypeHierarchical: postTypeObject?.hierarchical,\n\t\t\t\t\thasTermsAssigned:\n\t\t\t\t\t\t_post &&\n\t\t\t\t\t\t( taxonomies || [] )\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t( { visibility } ) =>\n\t\t\t\t\t\t\t\t\tvisibility?.publicly_queryable\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.some( ( taxonomy ) => {\n\t\t\t\t\t\t\t\treturn !! _post[ taxonomy.rest_base ]?.length;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\tisLoading:\n\t\t\t\t\t\t! _post ||\n\t\t\t\t\t\t! postTypeObject ||\n\t\t\t\t\t\t( postTypeHasTaxonomies && ! taxonomies ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ postType, postId ]\n\t\t);\n\n\t// Counter used to cache-bust `useServerSideRender`\n\t//\n\t// This is a catch-all signal to re-render the block when a post's title,\n\t// parent ID, or terms change.\n\t//\n\t// This is fundamentally imperfect, because there are other entities which\n\t// could change in the meantime (the titles of ancestor posts, or the\n\t// labels of taxonomy terms), hence the choice to re-render systematically\n\t// upon saving.\n\tconst [ invalidationKey, setInvalidationKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tsetInvalidationKey( ( c ) => c + 1 );\n\t}, [ post ] );\n\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { content } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: 'core/breadcrumbs',\n\t\turlQueryArgs: { post_id: postId, invalidationKey },\n\t} );\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\t// TODO: this should be handled better when we add more types.\n\tlet breadcrumbsType;\n\tconst isSpecificSupportedTypeSet = [\n\t\t'postWithAncestors',\n\t\t'postWithTerms',\n\t].includes( type );\n\tif ( isSpecificSupportedTypeSet ) {\n\t\tbreadcrumbsType = type;\n\t} else {\n\t\tbreadcrumbsType = isPostTypeHierarchical\n\t\t\t? 'postWithAncestors'\n\t\t\t: 'postWithTerms';\n\t}\n\tlet placeholder = null;\n\t// This is fragile because this block is server side rendered and we'll have to\n\t// update the placeholder html if the server side rendering output changes.\n\tconst showPlaceholder =\n\t\t! postId ||\n\t\t! postType ||\n\t\t// When `templateSlug` is set only show placeholder if the post type is not.\n\t\t// This is needed because when we are showing the template in post editor we\n\t\t// want to show the real breadcrumbs if we have the post type.\n\t\t( templateSlug && ! postType ) ||\n\t\t( breadcrumbsType === 'postWithAncestors' &&\n\t\t\t! isPostTypeHierarchical ) ||\n\t\t( breadcrumbsType === 'postWithTerms' && ! hasTermsAssigned );\n\tif ( showPlaceholder ) {\n\t\tconst placeholderItems = [\n\t\t\tshowHomeLink && __( 'Home' ),\n\t\t\t// For now if we are adding this in a template show a generic placeholder.\n\t\t\t...( templateSlug && ! isSpecificSupportedTypeSet\n\t\t\t\t? [ __( 'Page' ) ]\n\t\t\t\t: BREADCRUMB_TYPES[ breadcrumbsType ].placeholderItems ),\n\t\t].filter( Boolean );\n\t\tplaceholder = (\n\t\t\t<nav\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--separator': `'${ separator }'`,\n\t\t\t\t} }\n\t\t\t\tinert=\"true\"\n\t\t\t>\n\t\t\t\t<ol>\n\t\t\t\t\t{ placeholderItems.map( ( text, index ) => (\n\t\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t\t<a href={ `#breadcrumbs-pseudo-link-${ index }` }>\n\t\t\t\t\t\t\t\t{ text }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<span aria-current=\"page\">{ __( 'Current' ) }</span>\n\t\t\t\t\t</li>\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\ttype: typeDefaultValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Type' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => type !== typeDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\ttype: typeDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Type' ) }\n\t\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { type: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Auto' ),\n\t\t\t\t\t\t\t\t\tvalue: 'auto',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Post with ancestors' ),\n\t\t\t\t\t\t\t\t\tvalue: 'postWithAncestors',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Post with terms' ),\n\t\t\t\t\t\t\t\t\tvalue: 'postWithTerms',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thelp={ BREADCRUMB_TYPES[ type ].help }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showHomeLink }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHomeLink: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showHomeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => separator !== separatorDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\t\tvalue={ separator }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { separator: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\t\tif ( ! separator ) {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ showPlaceholder ? (\n\t\t\t\t\tplaceholder\n\t\t\t\t) : (\n\t\t\t\t\t<RawHTML inert=\"true\">{ content }</RawHTML>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA0HI,SA6DF,UA7DE,KA6CA,YA7CA;AAvHJ,SAAS,UAAU;AACnB,SAAS,mBAAmB,qBAAqB;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC;AAAA,OACM;AACP,SAAS,iBAA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,GAAI,gBAAiB;AAAA,cAC7B,kBAAgB;AAAA,cAChB,UAAW,MAAM,CAAE;AAAA,cACnB,YAAa,MACZ,cAAe;AAAA,gBACd,cAAc;AAAA,cACf,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,OAAQ,GAAI,gBAAiB;AAAA,kBAC7B,UAAW,CAAE,UACZ,cAAe,EAAE,cAAc,MAAM,CAAE;AAAA,kBAExC,SAAU;AAAA;AAAA,cACX;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,OAAQ,GAAI,WAAY;AAAA,cACxB,kBAAgB;AAAA,cAChB,UAAW,MAAM,cAAc;AAAA,cAC/B,YAAa,MACZ,cAAe;AAAA,gBACd,WAAW;AAAA,cACZ,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,uBAAqB;AAAA,kBACrB,cAAa;AAAA,kBACb,OAAQ,GAAI,WAAY;AAAA,kBACxB,OAAQ;AAAA,kBACR,UAAW,CAAE,UACZ,cAAe,EAAE,WAAW,MAAM,CAAE;AAAA,kBAErC,QAAS,MAAM;AACd,wBAAK,CAAE,WAAY;AAClB,oCAAe;AAAA,wBACd,WAAW;AAAA,sBACZ,CAAE;AAAA,oBACH;AAAA,kBACD;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,oBAAC,SAAM,GAAG,YACP,4BACD,cAEA,oBAAC,WAAQ,OAAM,QAAS,mBAAS,GAEnC;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBlock } from "@wordpress/blocks";
|
|
2
2
|
import { __unstableCreateElement as createElement } from "@wordpress/rich-text";
|
|
3
|
-
import {
|
|
3
|
+
import { getTransformedAttributes } from "../utils/get-transformed-attributes";
|
|
4
4
|
const transforms = {
|
|
5
5
|
from: [
|
|
6
6
|
{
|
|
@@ -33,21 +33,21 @@ const transforms = {
|
|
|
33
33
|
{},
|
|
34
34
|
// Loop the selected buttons.
|
|
35
35
|
buttons.map((attributes) => {
|
|
36
|
-
const { content
|
|
36
|
+
const { content } = attributes;
|
|
37
37
|
const element = createElement(document, content);
|
|
38
38
|
const text = element.innerText || "";
|
|
39
39
|
const link = element.querySelector("a");
|
|
40
40
|
const url = link?.getAttribute("href");
|
|
41
41
|
return createBlock("core/button", {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
metadata: getTransformedMetadata(
|
|
45
|
-
metadata,
|
|
42
|
+
...getTransformedAttributes(
|
|
43
|
+
attributes,
|
|
46
44
|
"core/button",
|
|
47
45
|
({ content: contentBinding }) => ({
|
|
48
46
|
text: contentBinding
|
|
49
47
|
})
|
|
50
|
-
)
|
|
48
|
+
),
|
|
49
|
+
text,
|
|
50
|
+
url
|
|
51
51
|
});
|
|
52
52
|
})
|
|
53
53
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/buttons/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,qBAAqB;AAKzD,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/button' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) =>\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\tcreateBlock( 'core/button', attributes )\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) => {\n\t\t\t\t\t\tconst { content } = attributes;\n\t\t\t\t\t\tconst element = createElement( document, content );\n\t\t\t\t\t\t// Remove any HTML tags.\n\t\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\t\t// Get first url.\n\t\t\t\t\t\tconst link = element.querySelector( 'a' );\n\t\t\t\t\t\tconst url = link?.getAttribute( 'href' );\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\treturn createBlock( 'core/button', {\n\t\t\t\t\t\t\t...getTransformedAttributes(\n\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\t'core/button',\n\t\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\t\ttext: contentBinding,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )\n\t\t\t\t),\n\t\t\tisMatch: ( paragraphs ) => {\n\t\t\t\treturn paragraphs.every( ( attributes ) => {\n\t\t\t\t\tconst element = createElement(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tattributes.content\n\t\t\t\t\t);\n\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\tconst links = element.querySelectorAll( 'a' );\n\t\t\t\t\treturn text.length <= 30 && links.length <= 1;\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,qBAAqB;AAKzD,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,aAAc;AAAA,MACxB,WAAW,CAAE;AAAA;AAAA,QAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ;AAAA,YAAK,CAAE;AAAA;AAAA,cAEd,YAAa,eAAe,UAAW;AAAA;AAAA,UACxC;AAAA,QACD;AAAA;AAAA,IACF;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE;AAAA;AAAA,QAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ,IAAK,CAAE,eAAgB;AAC9B,kBAAM,EAAE,QAAQ,IAAI;AACpB,kBAAM,UAAU,cAAe,UAAU,OAAQ;AAEjD,kBAAM,OAAO,QAAQ,aAAa;AAElC,kBAAM,OAAO,QAAQ,cAAe,GAAI;AACxC,kBAAM,MAAM,MAAM,aAAc,MAAO;AAEvC,mBAAO,YAAa,eAAe;AAAA,cAClC,GAAG;AAAA,gBACF;AAAA,gBACA;AAAA,gBACA,CAAE,EAAE,SAAS,eAAe,OAAS;AAAA,kBACpC,MAAM;AAAA,gBACP;AAAA,cACD;AAAA,cACA;AAAA,cACA;AAAA,YACD,CAAE;AAAA,UACH,CAAE;AAAA,QACH;AAAA;AAAA,MACD,SAAS,CAAE,eAAgB;AAC1B,eAAO,WAAW,MAAO,CAAE,eAAgB;AAC1C,gBAAM,UAAU;AAAA,YACf;AAAA,YACA,WAAW;AAAA,UACZ;AACA,gBAAM,OAAO,QAAQ,aAAa;AAClC,gBAAM,QAAQ,QAAQ,iBAAkB,GAAI;AAC5C,iBAAO,KAAK,UAAU,MAAM,MAAM,UAAU;AAAA,QAC7C,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBlock } from "@wordpress/blocks";
|
|
2
2
|
import { create, toHTMLString } from "@wordpress/rich-text";
|
|
3
|
-
import {
|
|
3
|
+
import { getTransformedAttributes } from "../utils/get-transformed-attributes";
|
|
4
4
|
const transforms = {
|
|
5
5
|
from: [
|
|
6
6
|
{
|
|
@@ -11,20 +11,24 @@ const transforms = {
|
|
|
11
11
|
{
|
|
12
12
|
type: "block",
|
|
13
13
|
blocks: ["core/paragraph"],
|
|
14
|
-
transform: (
|
|
15
|
-
content
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
transform: (attributes) => {
|
|
15
|
+
const { content } = attributes;
|
|
16
|
+
return createBlock("core/code", {
|
|
17
|
+
...getTransformedAttributes(attributes, "core/code"),
|
|
18
|
+
content
|
|
19
|
+
});
|
|
20
|
+
}
|
|
18
21
|
},
|
|
19
22
|
{
|
|
20
23
|
type: "block",
|
|
21
24
|
blocks: ["core/html"],
|
|
22
|
-
transform: (
|
|
25
|
+
transform: (attributes) => {
|
|
26
|
+
const { content: text } = attributes;
|
|
23
27
|
return createBlock("core/code", {
|
|
28
|
+
...getTransformedAttributes(attributes, "core/code"),
|
|
24
29
|
// The HTML is plain text (with plain line breaks), so
|
|
25
30
|
// convert it to rich text.
|
|
26
|
-
content: toHTMLString({ value: create({ text }) })
|
|
27
|
-
metadata: getTransformedMetadata(metadata, "core/code")
|
|
31
|
+
content: toHTMLString({ value: create({ text }) })
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
34
|
},
|
|
@@ -48,13 +52,13 @@ const transforms = {
|
|
|
48
52
|
{
|
|
49
53
|
type: "block",
|
|
50
54
|
blocks: ["core/paragraph"],
|
|
51
|
-
transform: (
|
|
52
|
-
content
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
}
|
|
55
|
+
transform: (attributes) => {
|
|
56
|
+
const { content } = attributes;
|
|
57
|
+
return createBlock("core/paragraph", {
|
|
58
|
+
...getTransformedAttributes(attributes, "core/paragraph"),
|
|
59
|
+
content
|
|
60
|
+
});
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
]
|
|
60
64
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,oBAAoB;AAKrC,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'enter',\n\t\t\tregExp: /^```$/,\n\t\t\ttransform: () => createBlock( 'core/code' ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content } = attributes;\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/code' ),\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/html' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content: text } = attributes;\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/code' ),\n\t\t\t\t\t// The HTML is plain text (with plain line breaks), so\n\t\t\t\t\t// convert it to rich text.\n\t\t\t\t\tcontent: toHTMLString( { value: create( { text } ) } ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'PRE' &&\n\t\t\t\tnode.children.length === 1 &&\n\t\t\t\tnode.firstChild.nodeName === 'CODE',\n\t\t\tschema: {\n\t\t\t\tpre: {\n\t\t\t\t\tchildren: {\n\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\tchildren: {\n\t\t\t\t\t\t\t\t'#text': {},\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],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content } = attributes;\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/paragraph' ),\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,oBAAoB;AAKrC,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW,MAAM,YAAa,WAAY;AAAA,IAC3C;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QA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./save";
|
|
8
8
|
import transforms from "./transforms";
|
|
9
|
-
import variations from "./variations";
|
|
10
9
|
const { name } = metadata;
|
|
11
10
|
const settings = {
|
|
12
11
|
icon,
|
|
@@ -45,8 +44,7 @@ const settings = {
|
|
|
45
44
|
};
|
|
46
45
|
},
|
|
47
46
|
edit,
|
|
48
|
-
save
|
|
49
|
-
variations
|
|
47
|
+
save
|
|
50
48
|
};
|
|
51
49
|
const init = () => initBlock({ name, metadata, settings });
|
|
52
50
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/heading/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\
|
|
5
|
-
"mappings": "AAGA,SAAS,WAAW,YAAY;AAChC,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t\ttextAlign: 'center',\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! hasContent\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,WAAW,YAAY;AAChC,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AAEvB,MAAM,EAAE,KAAK,IAAI;AAIV,MAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS,GAAI,gBAAiB;AAAA,MAC9B,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,CAAE,aACN;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,MACA,IACA;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,QACA;AAAA,MACA;AAAA,IACJ;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|