@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.
Files changed (173) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/build/breadcrumbs/block.json +8 -2
  4. package/build/breadcrumbs/edit.js +113 -12
  5. package/build/breadcrumbs/edit.js.map +2 -2
  6. package/build/buttons/transforms.js +7 -7
  7. package/build/buttons/transforms.js.map +2 -2
  8. package/build/code/transforms.js +19 -15
  9. package/build/code/transforms.js.map +2 -2
  10. package/build/heading/index.js +1 -3
  11. package/build/heading/index.js.map +3 -3
  12. package/build/heading/transforms.js +22 -20
  13. package/build/heading/transforms.js.map +2 -2
  14. package/build/index.js +5 -3
  15. package/build/index.js.map +2 -2
  16. package/build/math/block.json +21 -0
  17. package/build/math/edit.js +132 -0
  18. package/build/math/edit.js.map +7 -0
  19. package/build/math/index.js +63 -0
  20. package/build/math/index.js.map +7 -0
  21. package/build/math/init.js +35 -0
  22. package/build/math/init.js.map +7 -0
  23. package/build/math/save.js +40 -0
  24. package/build/math/save.js.map +7 -0
  25. package/build/navigation/edit/menu-inspector-controls.js +2 -2
  26. package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
  27. package/build/navigation-link/edit.js +5 -2
  28. package/build/navigation-link/edit.js.map +2 -2
  29. package/build/navigation-link/link-ui/index.js +1 -1
  30. package/build/navigation-link/link-ui/index.js.map +2 -2
  31. package/build/navigation-link/shared/controls.js +39 -16
  32. package/build/navigation-link/shared/controls.js.map +3 -3
  33. package/build/navigation-link/shared/index.js +2 -0
  34. package/build/navigation-link/shared/index.js.map +2 -2
  35. package/build/navigation-link/shared/update-attributes.js +3 -1
  36. package/build/navigation-link/shared/update-attributes.js.map +2 -2
  37. package/build/navigation-link/shared/use-entity-binding.js +46 -13
  38. package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
  39. package/build/navigation-submenu/edit.js +5 -2
  40. package/build/navigation-submenu/edit.js.map +2 -2
  41. package/build/page-list/use-convert-to-navigation-links.js +6 -1
  42. package/build/page-list/use-convert-to-navigation-links.js.map +2 -2
  43. package/build/paragraph/index.js +1 -3
  44. package/build/paragraph/index.js.map +3 -3
  45. package/build/post-date/deprecated.js +98 -2
  46. package/build/post-date/deprecated.js.map +2 -2
  47. package/build/post-date/edit.js +1 -1
  48. package/build/post-date/edit.js.map +1 -1
  49. package/build/post-date/variations.js +4 -4
  50. package/build/post-date/variations.js.map +2 -2
  51. package/build/term-template/block.json +0 -1
  52. package/build/term-template/edit.js +4 -1
  53. package/build/term-template/edit.js.map +2 -2
  54. package/build/terms-query/block.json +0 -1
  55. package/build/utils/get-transformed-attributes.js +82 -0
  56. package/build/utils/get-transformed-attributes.js.map +7 -0
  57. package/build-module/breadcrumbs/block.json +8 -2
  58. package/build-module/breadcrumbs/edit.js +117 -14
  59. package/build-module/breadcrumbs/edit.js.map +2 -2
  60. package/build-module/buttons/transforms.js +7 -7
  61. package/build-module/buttons/transforms.js.map +2 -2
  62. package/build-module/code/transforms.js +19 -15
  63. package/build-module/code/transforms.js.map +2 -2
  64. package/build-module/heading/index.js +1 -3
  65. package/build-module/heading/index.js.map +2 -2
  66. package/build-module/heading/transforms.js +22 -20
  67. package/build-module/heading/transforms.js.map +2 -2
  68. package/build-module/index.js +5 -3
  69. package/build-module/index.js.map +2 -2
  70. package/build-module/math/block.json +21 -0
  71. package/build-module/math/edit.js +110 -0
  72. package/build-module/math/edit.js.map +7 -0
  73. package/build-module/math/index.js +26 -0
  74. package/build-module/math/index.js.map +7 -0
  75. package/build-module/math/init.js +8 -0
  76. package/build-module/math/init.js.map +7 -0
  77. package/build-module/math/save.js +20 -0
  78. package/build-module/math/save.js.map +7 -0
  79. package/build-module/navigation/edit/menu-inspector-controls.js +2 -2
  80. package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
  81. package/build-module/navigation-link/edit.js +5 -2
  82. package/build-module/navigation-link/edit.js.map +2 -2
  83. package/build-module/navigation-link/link-ui/index.js +1 -1
  84. package/build-module/navigation-link/link-ui/index.js.map +2 -2
  85. package/build-module/navigation-link/shared/controls.js +40 -17
  86. package/build-module/navigation-link/shared/controls.js.map +2 -2
  87. package/build-module/navigation-link/shared/index.js +5 -1
  88. package/build-module/navigation-link/shared/index.js.map +2 -2
  89. package/build-module/navigation-link/shared/update-attributes.js +3 -1
  90. package/build-module/navigation-link/shared/update-attributes.js.map +2 -2
  91. package/build-module/navigation-link/shared/use-entity-binding.js +45 -13
  92. package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
  93. package/build-module/navigation-submenu/edit.js +5 -2
  94. package/build-module/navigation-submenu/edit.js.map +2 -2
  95. package/build-module/page-list/use-convert-to-navigation-links.js +6 -1
  96. package/build-module/page-list/use-convert-to-navigation-links.js.map +2 -2
  97. package/build-module/paragraph/index.js +1 -3
  98. package/build-module/paragraph/index.js.map +2 -2
  99. package/build-module/post-date/deprecated.js +98 -2
  100. package/build-module/post-date/deprecated.js.map +2 -2
  101. package/build-module/post-date/edit.js +1 -1
  102. package/build-module/post-date/edit.js.map +1 -1
  103. package/build-module/post-date/variations.js +4 -4
  104. package/build-module/post-date/variations.js.map +2 -2
  105. package/build-module/term-template/block.json +0 -1
  106. package/build-module/term-template/edit.js +4 -1
  107. package/build-module/term-template/edit.js.map +2 -2
  108. package/build-module/terms-query/block.json +0 -1
  109. package/build-module/utils/get-transformed-attributes.js +58 -0
  110. package/build-module/utils/get-transformed-attributes.js.map +7 -0
  111. package/build-style/editor-rtl.css +2 -2
  112. package/build-style/editor.css +2 -2
  113. package/build-style/navigation-link/editor-rtl.css +1 -1
  114. package/build-style/navigation-link/editor.css +1 -1
  115. package/build-style/video/editor-rtl.css +1 -1
  116. package/build-style/video/editor.css +1 -1
  117. package/package.json +61 -36
  118. package/src/breadcrumbs/block.json +8 -2
  119. package/src/breadcrumbs/edit.js +163 -18
  120. package/src/breadcrumbs/index.php +118 -16
  121. package/src/buttons/transforms.js +6 -6
  122. package/src/code/transforms.js +16 -14
  123. package/src/heading/index.js +0 -2
  124. package/src/heading/transforms.js +25 -24
  125. package/src/index.js +5 -3
  126. package/src/math/block.json +21 -0
  127. package/src/math/edit.js +123 -0
  128. package/src/math/index.js +31 -0
  129. package/src/math/init.js +4 -0
  130. package/src/math/save.js +20 -0
  131. package/src/navigation/edit/menu-inspector-controls.js +7 -6
  132. package/src/navigation-link/edit.js +5 -2
  133. package/src/navigation-link/editor.scss +1 -1
  134. package/src/navigation-link/index.php +4 -18
  135. package/src/navigation-link/link-ui/index.js +4 -2
  136. package/src/navigation-link/shared/controls.js +69 -20
  137. package/src/navigation-link/shared/index.js +4 -1
  138. package/src/navigation-link/shared/test/controls.js +14 -9
  139. package/src/navigation-link/shared/test/update-attributes.test.js +8 -0
  140. package/src/navigation-link/shared/test/use-entity-binding.js +132 -17
  141. package/src/navigation-link/shared/update-attributes.js +1 -0
  142. package/src/navigation-link/shared/use-entity-binding.js +74 -19
  143. package/src/navigation-submenu/edit.js +5 -2
  144. package/src/navigation-submenu/index.php +3 -17
  145. package/src/page-list/test/{convert-to-links-modal.js → convert-to-navigation-links.js} +67 -0
  146. package/src/page-list/use-convert-to-navigation-links.js +11 -1
  147. package/src/paragraph/index.js +0 -2
  148. package/src/post-date/deprecated.js +104 -2
  149. package/src/post-date/edit.js +1 -1
  150. package/src/post-date/index.php +3 -3
  151. package/src/post-date/variations.js +5 -4
  152. package/src/term-template/block.json +0 -1
  153. package/src/term-template/edit.js +4 -1
  154. package/src/term-template/index.php +4 -6
  155. package/src/terms-query/block.json +0 -1
  156. package/src/utils/get-transformed-attributes.js +98 -0
  157. package/src/video/editor.scss +1 -1
  158. package/tsconfig.json +1 -0
  159. package/build/heading/variations.js +0 -48
  160. package/build/heading/variations.js.map +0 -7
  161. package/build/paragraph/variations.js +0 -48
  162. package/build/paragraph/variations.js.map +0 -7
  163. package/build/utils/get-transformed-metadata.js +0 -65
  164. package/build/utils/get-transformed-metadata.js.map +0 -7
  165. package/build-module/heading/variations.js +0 -28
  166. package/build-module/heading/variations.js.map +0 -7
  167. package/build-module/paragraph/variations.js +0 -28
  168. package/build-module/paragraph/variations.js.map +0 -7
  169. package/build-module/utils/get-transformed-metadata.js +0 -41
  170. package/build-module/utils/get-transformed-metadata.js.map +0 -7
  171. package/src/heading/variations.js +0 -29
  172. package/src/paragraph/variations.js +0 -29
  173. 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,SA6HN,UA7HM,KAoHC,YApHD;AA3BR,OAAO,UAAU;AAKjB,SAAS,oBAAoB;AAC7B,SAAS,MAAM,YAAY;AAC3B,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,iBAAiB;AAC1B,SAAS,IAAI,UAAU;AACvB;AAAA,EACC;AAAA,EACA;AAAA,EACA,iCAAiC;AAAA,EACjC;A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BAAkB,EAAE,MAAM,UAAU,CAAE;AAAA,YACvC,UACC,eAAe,aACf,eAAe;AAAA,UACjB;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,cACN;AAAA,cACA;AAAA,YACD;AAAA,YACA,SAAS,MACR,iBAAkB;AAAA,cACjB,MAAM;AAAA,cACN;AAAA,YACD,CAAE;AAAA,YACH,UAAU,eAAe;AAAA,UAC1B;AAAA,QACD;AAAA;AAAA,IACD,GACD;AAAA,IACA,oBAAC,QAAK,GAAG,YACN,yBAAe,IAAK,CAAE,iBACvB;AAAA,MAAC;AAAA;AAAA,QAEA,OAAQ;AAAA,QAEN;AAAA,uBAAa,YACb,wBACD,cAAe,CAAE,GAAG,UACpB;AAAA,YAAC;AAAA;AAAA,cACA,WAAY,aAAa;AAAA;AAAA,UAC1B,IACG;AAAA,UACJ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,gBAAiB,aAAa;AAAA,cAC9B,WAAY,aAAa;AAAA,cACzB;AAAA,cACA,UACC,aAAa,YACX,wBACD,cAAe,CAAE,GAAG;AAAA;AAAA,UAEvB;AAAA;AAAA;AAAA,MApBM,aAAa;AAAA,IAqBpB,CACC,GACH;AAAA,KACD;AAEF;",
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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B;AAAA;AAAA;AAAA,MApBM,aAAa;AAAA,IAqBpB,CACC,GACH;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": true,
5
4
  "name": "core/terms-query",
6
5
  "title": "Terms Query",
7
6
  "category": "theme",
@@ -0,0 +1,58 @@
1
+ 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,SAAS,yBACf,YACA,cACA,mBAAmB,MAClB;AACD,MAAK,CAAE,YAAa;AACnB,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,aAAc,YAAa;AAChD,MAAK,CAAE,cAAe;AACrB,WAAO;AAAA,EACR;AAEA,QAAM,wBAAwB,CAAC;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op
1950
1950
  .link-control-transform__subheading {
1951
1951
  font-size: 11px;
1952
1952
  text-transform: uppercase;
1953
- font-weight: 500;
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: 500;
2600
+ font-weight: 499;
2601
2601
  display: block;
2602
2602
  }
2603
2603
 
@@ -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: 500;
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: 500;
2607
+ font-weight: 499;
2608
2608
  display: block;
2609
2609
  }
2610
2610
 
@@ -122,7 +122,7 @@
122
122
  .link-control-transform__subheading {
123
123
  font-size: 11px;
124
124
  text-transform: uppercase;
125
- font-weight: 500;
125
+ font-weight: 499;
126
126
  color: #1e1e1e;
127
127
  margin-bottom: 1.5em;
128
128
  }
@@ -122,7 +122,7 @@
122
122
  .link-control-transform__subheading {
123
123
  font-size: 11px;
124
124
  text-transform: uppercase;
125
- font-weight: 500;
125
+ font-weight: 499;
126
126
  color: #1e1e1e;
127
127
  margin-bottom: 1.5em;
128
128
  }
@@ -79,7 +79,7 @@
79
79
  color: #757575;
80
80
  text-transform: uppercase;
81
81
  font-size: 11px;
82
- font-weight: 500;
82
+ font-weight: 499;
83
83
  display: block;
84
84
  }
85
85
 
@@ -79,7 +79,7 @@
79
79
  color: #757575;
80
80
  text-transform: uppercase;
81
81
  font-size: 11px;
82
- font-weight: 500;
82
+ font-weight: 499;
83
83
  display: block;
84
84
  }
85
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "9.33.1-next.ff1cebbba.0",
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.32.1-next.ff1cebbba.0",
61
- "@wordpress/api-fetch": "^7.32.1-next.ff1cebbba.0",
62
- "@wordpress/autop": "^4.32.1-next.ff1cebbba.0",
63
- "@wordpress/base-styles": "^6.8.1-next.ff1cebbba.0",
64
- "@wordpress/blob": "^4.32.1-next.ff1cebbba.0",
65
- "@wordpress/block-editor": "^15.5.1-next.ff1cebbba.0",
66
- "@wordpress/blocks": "^15.5.1-next.ff1cebbba.0",
67
- "@wordpress/components": "^30.6.1-next.ff1cebbba.0",
68
- "@wordpress/compose": "^7.32.1-next.ff1cebbba.0",
69
- "@wordpress/core-data": "^7.32.1-next.ff1cebbba.0",
70
- "@wordpress/data": "^10.32.1-next.ff1cebbba.0",
71
- "@wordpress/date": "^5.32.1-next.ff1cebbba.0",
72
- "@wordpress/deprecated": "^4.32.1-next.ff1cebbba.0",
73
- "@wordpress/dom": "^4.32.1-next.ff1cebbba.0",
74
- "@wordpress/element": "^6.32.1-next.ff1cebbba.0",
75
- "@wordpress/escape-html": "^3.32.1-next.ff1cebbba.0",
76
- "@wordpress/hooks": "^4.32.1-next.ff1cebbba.0",
77
- "@wordpress/html-entities": "^4.32.1-next.ff1cebbba.0",
78
- "@wordpress/i18n": "^6.5.1-next.ff1cebbba.0",
79
- "@wordpress/icons": "^11.0.1-next.ff1cebbba.0",
80
- "@wordpress/interactivity": "^6.33.1-next.ff1cebbba.0",
81
- "@wordpress/interactivity-router": "^2.32.1-next.ff1cebbba.0",
82
- "@wordpress/keyboard-shortcuts": "^5.32.1-next.ff1cebbba.0",
83
- "@wordpress/keycodes": "^4.32.1-next.ff1cebbba.0",
84
- "@wordpress/notices": "^5.32.1-next.ff1cebbba.0",
85
- "@wordpress/patterns": "^2.32.1-next.ff1cebbba.0",
86
- "@wordpress/primitives": "^4.32.1-next.ff1cebbba.0",
87
- "@wordpress/private-apis": "^1.32.1-next.ff1cebbba.0",
88
- "@wordpress/reusable-blocks": "^5.32.1-next.ff1cebbba.0",
89
- "@wordpress/rich-text": "^7.32.1-next.ff1cebbba.0",
90
- "@wordpress/server-side-render": "^6.8.1-next.ff1cebbba.0",
91
- "@wordpress/url": "^4.32.1-next.ff1cebbba.0",
92
- "@wordpress/viewport": "^6.32.1-next.ff1cebbba.0",
93
- "@wordpress/wordcount": "^4.32.1-next.ff1cebbba.0",
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": "c5b659710aff01d40d2eb97b211eb2cec9c07d3b"
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 only for Pages, or for hierarchical post types. The block is useful to insert in the Pages template.",
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": {
@@ -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 = useSelect(
30
- ( select ) => {
31
- if ( ! postType ) {
32
- return null;
33
- }
34
- return select( coreStore ).getPostType( postType )?.hierarchical;
35
- },
36
- [ postType ]
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
- if ( ! postId || ! postType || ! isPostTypeHierarchical ) {
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
- __( 'Ancestor' ),
54
- __( 'Parent' ),
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
- { placeholder || <RawHTML inert="true">{ content }</RawHTML> }
282
+ { showPlaceholder ? (
283
+ placeholder
284
+ ) : (
285
+ <RawHTML inert="true">{ content }</RawHTML>
286
+ ) }
142
287
  </div>
143
288
  </>
144
289
  );