@wordpress/block-library 7.14.1 → 7.14.3

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 (41) hide show
  1. package/build/comments-pagination-next/index.js +1 -1
  2. package/build/comments-pagination-numbers/index.js +1 -1
  3. package/build/comments-pagination-previous/index.js +1 -1
  4. package/build/gallery/deprecated.js +4 -4
  5. package/build/gallery/deprecated.js.map +1 -1
  6. package/build/navigation/menu-items-to-blocks.js +16 -6
  7. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  8. package/build/post-template/edit.js +13 -28
  9. package/build/post-template/edit.js.map +1 -1
  10. package/build/quote/transforms.js +2 -2
  11. package/build/quote/transforms.js.map +1 -1
  12. package/build/template-part/edit/index.js +2 -2
  13. package/build/template-part/edit/index.js.map +1 -1
  14. package/build-module/comments-pagination-next/index.js +1 -1
  15. package/build-module/comments-pagination-numbers/index.js +1 -1
  16. package/build-module/comments-pagination-previous/index.js +1 -1
  17. package/build-module/gallery/deprecated.js +4 -4
  18. package/build-module/gallery/deprecated.js.map +1 -1
  19. package/build-module/navigation/menu-items-to-blocks.js +16 -6
  20. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  21. package/build-module/post-template/edit.js +14 -29
  22. package/build-module/post-template/edit.js.map +1 -1
  23. package/build-module/quote/transforms.js +2 -2
  24. package/build-module/quote/transforms.js.map +1 -1
  25. package/build-module/template-part/edit/index.js +3 -3
  26. package/build-module/template-part/edit/index.js.map +1 -1
  27. package/build-style/classic-rtl.css +85 -0
  28. package/build-style/classic.css +85 -0
  29. package/package.json +28 -28
  30. package/src/classic.scss +15 -0
  31. package/src/comment-template/index.php +18 -8
  32. package/src/comments-pagination-next/block.json +1 -1
  33. package/src/comments-pagination-numbers/block.json +1 -1
  34. package/src/comments-pagination-previous/block.json +1 -1
  35. package/src/gallery/deprecated.js +4 -4
  36. package/src/navigation/menu-items-to-blocks.js +39 -22
  37. package/src/navigation/test/menu-items-to-blocks.js +6 -0
  38. package/src/navigation-submenu/index.php +10 -1
  39. package/src/post-template/edit.js +14 -23
  40. package/src/quote/transforms.js +1 -1
  41. package/src/template-part/edit/index.js +60 -58
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
14
14
  import { __ } from '@wordpress/i18n';
15
15
  import { BlockContextProvider, __experimentalUseBlockPreview as useBlockPreview, useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
16
16
  import { Spinner } from '@wordpress/components';
17
- import { store as coreStore, useEntityRecords } from '@wordpress/core-data';
17
+ import { store as coreStore } from '@wordpress/core-data';
18
18
  const TEMPLATE = [['core/post-title'], ['core/post-date'], ['core/post-excerpt']];
19
19
 
20
20
  function PostTemplateInnerBlocks() {
@@ -98,21 +98,6 @@ export default function PostTemplateEdit(_ref2) {
98
98
  page
99
99
  }] = queryContext;
100
100
  const [activeBlockContextId, setActiveBlockContextId] = useState();
101
- let categorySlug = null;
102
-
103
- if (templateSlug !== null && templateSlug !== void 0 && templateSlug.startsWith('category-')) {
104
- categorySlug = templateSlug.replace('category-', '');
105
- }
106
-
107
- const {
108
- records: categories,
109
- hasResolved: hasResolvedCategories
110
- } = useEntityRecords('taxonomy', 'category', {
111
- context: 'view',
112
- per_page: -1,
113
- _fields: ['id'],
114
- slug: categorySlug
115
- });
116
101
  const {
117
102
  posts,
118
103
  blocks
@@ -129,13 +114,19 @@ export default function PostTemplateEdit(_ref2) {
129
114
  per_page: -1,
130
115
  context: 'view'
131
116
  });
117
+ const templateCategory = inherit && (templateSlug === null || templateSlug === void 0 ? void 0 : templateSlug.startsWith('category-')) && getEntityRecords('taxonomy', 'category', {
118
+ context: 'view',
119
+ per_page: 1,
120
+ _fields: ['id'],
121
+ slug: templateSlug.replace('category-', '')
122
+ });
132
123
  const query = {
133
124
  offset: perPage ? perPage * (page - 1) + offset : 0,
134
125
  order,
135
126
  orderby: orderBy
136
- };
127
+ }; // There is no need to build the taxQuery if we inherit.
137
128
 
138
- if (taxQuery) {
129
+ if (taxQuery && !inherit) {
139
130
  // We have to build the tax query for the REST API and use as
140
131
  // keys the taxonomies `rest_base` with the `term ids` as values.
141
132
  const builtTaxQuery = Object.entries(taxQuery).reduce((accumulator, _ref3) => {
@@ -192,16 +183,10 @@ export default function PostTemplateEdit(_ref2) {
192
183
  if (templateSlug !== null && templateSlug !== void 0 && templateSlug.startsWith('archive-')) {
193
184
  query.postType = templateSlug.replace('archive-', '');
194
185
  postType = query.postType;
195
- } else if (!!categorySlug && hasResolvedCategories) {
196
- query.taxQuery = {
197
- category: categories.map(_ref5 => {
198
- let {
199
- id
200
- } = _ref5;
201
- return id;
202
- })
203
- };
204
- taxQuery = query.taxQuery;
186
+ } else if (templateCategory) {
187
+ var _templateCategory$;
188
+
189
+ query.categories = (_templateCategory$ = templateCategory[0]) === null || _templateCategory$ === void 0 ? void 0 : _templateCategory$.id;
205
190
  }
206
191
  } // When we preview Query Loop blocks we should prefer the current
207
192
  // block's postType, which is passed through block context.
@@ -214,7 +199,7 @@ export default function PostTemplateEdit(_ref2) {
214
199
  }),
215
200
  blocks: getBlocks(clientId)
216
201
  };
217
- }, [perPage, page, offset, order, orderBy, clientId, author, search, postType, exclude, sticky, inherit, templateSlug, taxQuery, parents, restQueryArgs, previewPostType, categories, categorySlug, hasResolvedCategories]);
202
+ }, [perPage, page, offset, order, orderBy, clientId, author, search, postType, exclude, sticky, inherit, templateSlug, taxQuery, parents, restQueryArgs, previewPostType]);
218
203
  const blockContexts = useMemo(() => posts === null || posts === void 0 ? void 0 : posts.map(post => ({
219
204
  postType: post.type,
220
205
  postId: post.id
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-template/edit.js"],"names":["classnames","memo","useMemo","useState","useSelect","__","BlockContextProvider","__experimentalUseBlockPreview","useBlockPreview","useBlockProps","useInnerBlocksProps","store","blockEditorStore","Spinner","coreStore","useEntityRecords","TEMPLATE","PostTemplateInnerBlocks","innerBlocksProps","className","template","PostTemplateBlockPreview","blocks","blockContextId","isHidden","setActiveBlockContextId","blockPreviewProps","props","handleOnClick","style","display","undefined","MemoizedPostTemplateBlockPreview","PostTemplateEdit","clientId","context","query","perPage","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","pages","restQueryArgs","queryContext","page","templateSlug","displayLayout","type","layoutType","columns","previewPostType","activeBlockContextId","categorySlug","startsWith","replace","records","categories","hasResolved","hasResolvedCategories","per_page","_fields","slug","posts","select","getEntityRecords","getTaxonomies","getBlocks","taxonomies","orderby","builtTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","taxonomy","find","rest_base","keys","length","assign","parent","category","map","id","usedPostType","blockContexts","post","postId","hasLayoutFlex","blockProps","blockContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,OAAf,EAAwBC,QAAxB,QAAwC,oBAAxC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,oBADD,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,aAHD,EAICC,mBAJD,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASF,KAAK,IAAIG,SAAlB,EAA6BC,gBAA7B,QAAqD,sBAArD;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,iBAAF,CADgB,EAEhB,CAAE,gBAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,CAAjB;;AAMA,SAASC,uBAAT,GAAmC;AAClC,QAAMC,gBAAgB,GAAGR,mBAAmB,CAC3C;AAAES,IAAAA,SAAS,EAAE;AAAb,GAD2C,EAE3C;AAAEC,IAAAA,QAAQ,EAAEJ;AAAZ,GAF2C,CAA5C;AAIA,SAAO,oBAASE,gBAAT,CAAP;AACA;;AAED,SAASG,wBAAT,OAKI;AAAA,MAL+B;AAClCC,IAAAA,MADkC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,OAHC,GAIE,IARL,EASC,cAAC,gCAAD;AACC,MAAA,MAAM,EAAG3E,MADV;AAEC,MAAA,cAAc,EAAG8E,YAAY,CAACH,MAF/B;AAGC,MAAA,uBAAuB,EAAGxE,uBAH3B;AAIC,MAAA,QAAQ,EACP2E,YAAY,CAACH,MAAb,MACEtC,oBAAoB,yBACrBoC,aAAa,CAAE,CAAF,CADQ,qDACrB,iBAAoBE,MADC,CADtB;AALF,MATD,CADkB;AAAA,GAAnB,CAFF,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[ 'core/post-date' ],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks() {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: 'wp-block-post' },\n\t\t{ template: TEMPLATE }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: 'wp-block-post',\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpages,\n\t\t\t// We gather extra query args to pass to the REST API call.\n\t\t\t// This way extenders of Query Loop can add their own query args,\n\t\t\t// and have accurate previews in the editor.\n\t\t\t// Noting though that these args should either be supported by the\n\t\t\t// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.\n\t\t\t...restQueryArgs\n\t\t} = {},\n\t\tqueryContext = [ { page: 1 } ],\n\t\ttemplateSlug,\n\t\tdisplayLayout: { type: layoutType = 'flex', columns = 1 } = {},\n\t\tpreviewPostType,\n\t},\n} ) {\n\tconst [ { page } ] = queryContext;\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\n\tlet categorySlug = null;\n\tif ( templateSlug?.startsWith( 'category-' ) ) {\n\t\tcategorySlug = templateSlug.replace( 'category-', '' );\n\t}\n\tconst { records: categories, hasResolved: hasResolvedCategories } =\n\t\tuseEntityRecords( 'taxonomy', 'category', {\n\t\t\tcontext: 'view',\n\t\t\tper_page: -1,\n\t\t\t_fields: [ 'id' ],\n\t\t\tslug: categorySlug,\n\t\t} );\n\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: perPage ? perPage * ( page - 1 ) + offset : 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\tif ( taxQuery ) {\n\t\t\t\t// We have to build the tax query for the REST API and use as\n\t\t\t\t// keys the taxonomies `rest_base` with the `term ids` as values.\n\t\t\t\tconst builtTaxQuery = Object.entries( taxQuery ).reduce(\n\t\t\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( taxonomy?.rest_base ) {\n\t\t\t\t\t\t\taccumulator[ taxonomy?.rest_base ] = terms;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\t// If sticky is not set, it will return all posts in the results.\n\t\t\t// If sticky is set to `only`, it will limit the results to sticky posts only.\n\t\t\t// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.\n\t\t\tif ( sticky ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tpostType = query.postType;\n\t\t\t\t} else if ( !! categorySlug && hasResolvedCategories ) {\n\t\t\t\t\tquery.taxQuery = {\n\t\t\t\t\t\tcategory: categories.map( ( { id } ) => id ),\n\t\t\t\t\t};\n\t\t\t\t\ttaxQuery = query.taxQuery;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || postType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, {\n\t\t\t\t\t...query,\n\t\t\t\t\t...restQueryArgs,\n\t\t\t\t} ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\tpage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\trestQueryArgs,\n\t\t\tpreviewPostType,\n\t\t\tcategories,\n\t\t\tcategorySlug,\n\t\t\thasResolvedCategories,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\tconst hasLayoutFlex = layoutType === 'flex' && columns > 1;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t'is-flex-container': hasLayoutFlex,\n\t\t\t[ `columns-${ columns }` ]: hasLayoutFlex,\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<ul { ...blockProps }>\n\t\t\t{ blockContexts &&\n\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t<PostTemplateInnerBlocks />\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\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.postId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\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</ul>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-template/edit.js"],"names":["classnames","memo","useMemo","useState","useSelect","__","BlockContextProvider","__experimentalUseBlockPreview","useBlockPreview","useBlockProps","useInnerBlocksProps","store","blockEditorStore","Spinner","coreStore","TEMPLATE","PostTemplateInnerBlocks","innerBlocksProps","className","template","PostTemplateBlockPreview","blocks","blockContextId","isHidden","setActiveBlockContextId","blockPreviewProps","props","handleOnClick","style","display","undefined","MemoizedPostTemplateBlockPreview","PostTemplateEdit","clientId","context","query","perPage","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","pages","restQueryArgs","queryContext","page","templateSlug","displayLayout","type","layoutType","columns","previewPostType","activeBlockContextId","posts","select","getEntityRecords","getTaxonomies","getBlocks","taxonomies","per_page","templateCategory","startsWith","_fields","slug","replace","orderby","builtTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","taxonomy","find","rest_base","keys","length","assign","parent","categories","id","usedPostType","blockContexts","map","post","postId","hasLayoutFlex","blockProps","blockContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,OAAf,EAAwBC,QAAxB,QAAwC,oBAAxC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,oBADD,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,aAHD,EAICC,mBAJD,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASF,KAAK,IAAIG,SAAlB,QAAmC,sBAAnC;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,iBAAF,CADgB,EAEhB,CAAE,gBAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,CAAjB;;AAMA,SAASC,uBAAT,GAAmC;AAClC,QAAMC,gBAAgB,GAAGP,mBAAmB,CAC3C;AAAEQ,IAAAA,SAAS,EAAE;AAAb,GAD2C,EAE3C;AAAEC,IAAAA,QAAQ,EAAEJ;AAAZ,GAF2C,CAA5C;AAIA,SAAO,oBAASE,gBAAT,CAAP;AACA;;AAED,SAASG,wBAAT,OAKI;AAAA,MAL+B;AAClCC,IAAAA,MADkC;A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ADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[ 'core/post-date' ],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks() {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: 'wp-block-post' },\n\t\t{ template: TEMPLATE }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: 'wp-block-post',\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpages,\n\t\t\t// We gather extra query args to pass to the REST API call.\n\t\t\t// This way extenders of Query Loop can add their own query args,\n\t\t\t// and have accurate previews in the editor.\n\t\t\t// Noting though that these args should either be supported by the\n\t\t\t// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.\n\t\t\t...restQueryArgs\n\t\t} = {},\n\t\tqueryContext = [ { page: 1 } ],\n\t\ttemplateSlug,\n\t\tdisplayLayout: { type: layoutType = 'flex', columns = 1 } = {},\n\t\tpreviewPostType,\n\t},\n} ) {\n\tconst [ { page } ] = queryContext;\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst templateCategory =\n\t\t\t\tinherit &&\n\t\t\t\ttemplateSlug?.startsWith( 'category-' ) &&\n\t\t\t\tgetEntityRecords( 'taxonomy', 'category', {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\t_fields: [ 'id' ],\n\t\t\t\t\tslug: templateSlug.replace( 'category-', '' ),\n\t\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: perPage ? perPage * ( page - 1 ) + offset : 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\t// There is no need to build the taxQuery if we inherit.\n\t\t\tif ( taxQuery && ! inherit ) {\n\t\t\t\t// We have to build the tax query for the REST API and use as\n\t\t\t\t// keys the taxonomies `rest_base` with the `term ids` as values.\n\t\t\t\tconst builtTaxQuery = Object.entries( taxQuery ).reduce(\n\t\t\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( taxonomy?.rest_base ) {\n\t\t\t\t\t\t\taccumulator[ taxonomy?.rest_base ] = terms;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\t// If sticky is not set, it will return all posts in the results.\n\t\t\t// If sticky is set to `only`, it will limit the results to sticky posts only.\n\t\t\t// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.\n\t\t\tif ( sticky ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tpostType = query.postType;\n\t\t\t\t} else if ( templateCategory ) {\n\t\t\t\t\tquery.categories = templateCategory[ 0 ]?.id;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || postType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, {\n\t\t\t\t\t...query,\n\t\t\t\t\t...restQueryArgs,\n\t\t\t\t} ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\tpage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\trestQueryArgs,\n\t\t\tpreviewPostType,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\tconst hasLayoutFlex = layoutType === 'flex' && columns > 1;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t'is-flex-container': hasLayoutFlex,\n\t\t\t[ `columns-${ columns }` ]: hasLayoutFlex,\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<ul { ...blockProps }>\n\t\t\t{ blockContexts &&\n\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t<PostTemplateInnerBlocks />\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\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.postId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\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</ul>\n\t);\n}\n"]}
@@ -19,9 +19,9 @@ const transforms = {
19
19
  anchor,
20
20
  fontSize,
21
21
  style
22
- }, createBlock('core/paragraph', {
22
+ }, [createBlock('core/paragraph', {
23
23
  content: value
24
- }));
24
+ })]);
25
25
  }
26
26
  }, {
27
27
  type: 'block',
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/quote/transforms.js"],"names":["createBlock","transforms","from","type","blocks","transform","value","citation","anchor","fontSize","style","content","innerBlocks","prefix","schema","blockquote","children","selector","node","handler","HTML","innerHTML","mode","isMultiBlock","isMatch","length","includes","name","some","__experimentalConvert","map","block","attributes","to","every","join"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AAEA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,CACL;AACCC,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,MAAM,EAAE,CAAE,gBAAF,CAFT;AAGCC,IAAAA,SAAS,EAAE,QAAoD;AAAA,UAA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ies\n */\nimport { createBlock } from '@wordpress/blocks';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/pullquote' ],\n\t\t\ttransform: ( { value, citation, anchor, fontSize, style } ) => {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/quote',\n\t\t\t\t\t{\n\t\t\t\t\t\tcitation,\n\t\t\t\t\t\tanchor,\n\t\t\t\t\t\tfontSize,\n\t\t\t\t\t\tstyle,\n\t\t\t\t\t},\n\t\t\t\t\tcreateBlock( 'core/paragraph', { content: value } )\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/group' ],\n\t\t\ttransform: ( { anchor }, innerBlocks ) =>\n\t\t\t\tcreateBlock( 'core/quote', { anchor }, innerBlocks ),\n\t\t},\n\t\t{\n\t\t\ttype: 'prefix',\n\t\t\tprefix: '>',\n\t\t\ttransform: ( content ) =>\n\t\t\t\tcreateBlock( 'core/quote', {}, [\n\t\t\t\t\tcreateBlock( 'core/paragraph', { content } ),\n\t\t\t\t] ),\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tschema: () => ( {\n\t\t\t\tblockquote: {\n\t\t\t\t\tchildren: '*',\n\t\t\t\t},\n\t\t\t} ),\n\t\t\tselector: 'blockquote',\n\t\t\ttransform: ( node, handler ) => {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/quote',\n\t\t\t\t\t// Don't try to parse any `cite` out of this content.\n\t\t\t\t\t// * There may be more than one cite.\n\t\t\t\t\t// * There may be more attribution text than just the cite.\n\t\t\t\t\t// * If the cite is nested in the quoted text, it's wrong to\n\t\t\t\t\t// remove it.\n\t\t\t\t\t{},\n\t\t\t\t\thandler( {\n\t\t\t\t\t\tHTML: node.innerHTML,\n\t\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\tisMatch: ( {}, blocks ) => {\n\t\t\t\t// When a single block is selected make the tranformation\n\t\t\t\t// available only to specific blocks that make sense.\n\t\t\t\tif ( blocks.length === 1 ) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t'core/paragraph',\n\t\t\t\t\t\t'core/heading',\n\t\t\t\t\t\t'core/list',\n\t\t\t\t\t\t'core/pullquote',\n\t\t\t\t\t].includes( blocks[ 0 ].name );\n\t\t\t\t}\n\t\t\t\treturn ! blocks.some( ( { name } ) => name === 'core/quote' );\n\t\t\t},\n\t\t\t__experimentalConvert: ( blocks ) =>\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/quote',\n\t\t\t\t\t{},\n\t\t\t\t\tblocks.map( ( block ) =>\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/pullquote' ],\n\t\t\tisMatch: ( {}, block ) => {\n\t\t\t\treturn block.innerBlocks.every(\n\t\t\t\t\t( { name } ) => name === 'core/paragraph'\n\t\t\t\t);\n\t\t\t},\n\t\t\ttransform: (\n\t\t\t\t{ citation, anchor, fontSize, style },\n\t\t\t\tinnerBlocks\n\t\t\t) => {\n\t\t\t\tconst value = innerBlocks\n\t\t\t\t\t.map( ( { attributes } ) => `${ attributes.content }` )\n\t\t\t\t\t.join( '<br>' );\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue,\n\t\t\t\t\tcitation,\n\t\t\t\t\tanchor,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tstyle,\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/group' ],\n\t\t\ttransform: ( { citation, anchor }, innerBlocks ) =>\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{ anchor },\n\t\t\t\t\tcitation\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t...innerBlocks,\n\t\t\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: innerBlocks\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ '*' ],\n\t\t\ttransform: ( { citation }, innerBlocks ) =>\n\t\t\t\tcitation\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t...innerBlocks,\n\t\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: innerBlocks,\n\t\t},\n\t],\n};\n\nexport default transforms;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/quote/transforms.js"],"names":["createBlock","transforms","from","type","blocks","transform","value","citation","anchor","fontSize","style","content","innerBlocks","prefix","schema","blockquote","children","selector","node","handler","HTML","innerHTML","mode","isMultiBlock","isMatch","length","includes","name","some","__experimentalConvert","map","block","attributes","to","every","join"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AAEA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,CACL;AACCC,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,MAAM,EAAE,CAAE,gBAAF,CAFT;AAGCC,IAAAA,SAAS,EAAE,QAAoD;AAAA,UAAlD;AAAEC,QAAAA,KAAF;AAASC,QAAAA,QAAT;AAAmBC,QAAAA,MAAnB;AAA2BC,QAAAA,QAA3B;AAAqCC,QAAAA;AAArC,OAAkD;AAC9D,aAA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CACvBkB,GADY,CACP;AAAA,YAAE;AAAEE,UAAAA;AAAF,SAAF;AAAA,eAAuB,GAAGA,UAAU,CAACrB,OAAS,EAA9C;AAAA,OADO,EAEZwB,IAFY,CAEN,MAFM,CAAd;AAGA,aAAOnC,WAAW,CAAE,gBAAF,EAAoB;AACrCM,QAAAA,KADqC;AAErCC,QAAAA,QAFqC;AAGrCC,QAAAA,MAHqC;AAIrCC,QAAAA,QAJqC;AAKrCC,QAAAA;AALqC,OAApB,CAAlB;AAOA;AAtBF,GADG,EAyBH;AACCP,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,MAAM,EAAE,CAAE,YAAF,CAFT;AAGCC,IAAAA,SAAS,EAAE,QAAwBO,WAAxB;AAAA,UAAE;AAAEL,QAAAA,QAAF;AAAYC,QAAAA;AAAZ,OAAF;AAAA,aACVR,WAAW,CACV,YADU,EAEV;AAAEQ,QAAAA;AAAF,OAFU,EAGVD,QAAQ,GACL,CACA,GAAGK,WADH,EAEAZ,WAAW,CAAE,gBAAF,EAAoB;AAC9BW,QAAAA,OAAO,EAAEJ;AADqB,OAApB,CAFX,CADK,GAOLK,WAVO,CADD;AAAA;AAHZ,GAzBG,EA0CH;AACCT,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,MAAM,EAAE,CAAE,GAAF,CAFT;AAGCC,IAAAA,SAAS,EAAE,SAAgBO,WAAhB;AAAA,UAAE;AAAEL,QAAAA;AAAF,OAAF;AAAA,aACVA,QAAQ,GACL,CACA,GAAGK,WADH,EAEAZ,WAAW,CAAE,gBAAF,EAAoB;AAC9BW,QAAAA,OAAO,EAAEJ;AADqB,OAApB,CAFX,CADK,GAOLK,WARO;AAAA;AAHZ,GA1CG;AAvFc,CAAnB;AAiJA,eAAeX,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/pullquote' ],\n\t\t\ttransform: ( { value, citation, anchor, fontSize, style } ) => {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/quote',\n\t\t\t\t\t{\n\t\t\t\t\t\tcitation,\n\t\t\t\t\t\tanchor,\n\t\t\t\t\t\tfontSize,\n\t\t\t\t\t\tstyle,\n\t\t\t\t\t},\n\t\t\t\t\t[ createBlock( 'core/paragraph', { content: value } ) ]\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/group' ],\n\t\t\ttransform: ( { anchor }, innerBlocks ) =>\n\t\t\t\tcreateBlock( 'core/quote', { anchor }, innerBlocks ),\n\t\t},\n\t\t{\n\t\t\ttype: 'prefix',\n\t\t\tprefix: '>',\n\t\t\ttransform: ( content ) =>\n\t\t\t\tcreateBlock( 'core/quote', {}, [\n\t\t\t\t\tcreateBlock( 'core/paragraph', { content } ),\n\t\t\t\t] ),\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tschema: () => ( {\n\t\t\t\tblockquote: {\n\t\t\t\t\tchildren: '*',\n\t\t\t\t},\n\t\t\t} ),\n\t\t\tselector: 'blockquote',\n\t\t\ttransform: ( node, handler ) => {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/quote',\n\t\t\t\t\t// Don't try to parse any `cite` out of this content.\n\t\t\t\t\t// * There may be more than one cite.\n\t\t\t\t\t// * There may be more attribution text than just the cite.\n\t\t\t\t\t// * If the cite is nested in the quoted text, it's wrong to\n\t\t\t\t\t// remove it.\n\t\t\t\t\t{},\n\t\t\t\t\thandler( {\n\t\t\t\t\t\tHTML: node.innerHTML,\n\t\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\tisMatch: ( {}, blocks ) => {\n\t\t\t\t// When a single block is selected make the tranformation\n\t\t\t\t// available only to specific blocks that make sense.\n\t\t\t\tif ( blocks.length === 1 ) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t'core/paragraph',\n\t\t\t\t\t\t'core/heading',\n\t\t\t\t\t\t'core/list',\n\t\t\t\t\t\t'core/pullquote',\n\t\t\t\t\t].includes( blocks[ 0 ].name );\n\t\t\t\t}\n\t\t\t\treturn ! blocks.some( ( { name } ) => name === 'core/quote' );\n\t\t\t},\n\t\t\t__experimentalConvert: ( blocks ) =>\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/quote',\n\t\t\t\t\t{},\n\t\t\t\t\tblocks.map( ( block ) =>\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/pullquote' ],\n\t\t\tisMatch: ( {}, block ) => {\n\t\t\t\treturn block.innerBlocks.every(\n\t\t\t\t\t( { name } ) => name === 'core/paragraph'\n\t\t\t\t);\n\t\t\t},\n\t\t\ttransform: (\n\t\t\t\t{ citation, anchor, fontSize, style },\n\t\t\t\tinnerBlocks\n\t\t\t) => {\n\t\t\t\tconst value = innerBlocks\n\t\t\t\t\t.map( ( { attributes } ) => `${ attributes.content }` )\n\t\t\t\t\t.join( '<br>' );\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue,\n\t\t\t\t\tcitation,\n\t\t\t\t\tanchor,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tstyle,\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/group' ],\n\t\t\ttransform: ( { citation, anchor }, innerBlocks ) =>\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{ anchor },\n\t\t\t\t\tcitation\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t...innerBlocks,\n\t\t\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: innerBlocks\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ '*' ],\n\t\t\ttransform: ( { citation }, innerBlocks ) =>\n\t\t\t\tcitation\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t...innerBlocks,\n\t\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: innerBlocks,\n\t\t},\n\t],\n};\n\nexport default transforms;\n"]}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * External dependencies
@@ -94,7 +94,7 @@ export default function TemplatePartEdit(_ref) {
94
94
  return createElement(TagName, blockProps, createElement(Warning, null, __('Block cannot be rendered inside itself.')));
95
95
  }
96
96
 
97
- return createElement(RecursionProvider, {
97
+ return createElement(Fragment, null, createElement(RecursionProvider, {
98
98
  uniqueId: templatePartId
99
99
  }, createElement(TemplatePartAdvancedControls, {
100
100
  tagName: tagName,
@@ -123,7 +123,7 @@ export default function TemplatePartEdit(_ref) {
123
123
  postId: templatePartId,
124
124
  hasInnerBlocks: innerBlocks.length > 0,
125
125
  layout: layout
126
- }), !isPlaceholder && !isResolved && createElement(TagName, blockProps, createElement(Spinner, null)), isTemplatePartSelectionOpen && createElement(Modal, {
126
+ }), !isPlaceholder && !isResolved && createElement(TagName, blockProps, createElement(Spinner, null))), isTemplatePartSelectionOpen && createElement(Modal, {
127
127
  overlayClassName: "block-editor-template-part__selection-modal",
128
128
  title: sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
129
129
  __('Choose a %s'), areaObject.label.toLowerCase()),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["isEmpty","useSelect","BlockSettingsMenuControls","BlockTitle","useBlockProps","Warning","store","blockEditorStore","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Spinner","Modal","MenuItem","__","sprintf","coreStore","useState","createInterpolateElement","TemplatePartPlaceholder","TemplatePartSelectionModal","TemplatePartAdvancedControls","TemplatePartInnerBlocks","createTemplatePartId","useAlternativeBlockPatterns","useAlternativeTemplateParts","useTemplatePartArea","TemplatePartEdit","attributes","setAttributes","clientId","isSelected","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","getBlocks","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","canReplace","label","toLowerCase"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,yBADD,EAECC,UAFD,EAGCC,aAHD,EAICC,OAJD,EAKCC,KAAK,IAAIC,gBALV,EAMCC,+BAA+B,IAAIC,iBANpC,EAOCC,6BAA6B,IAAIC,eAPlC,QAQO,yBARP;AASA,SAASC,OAAT,EAAkBC,KAAlB,EAAyBC,QAAzB,QAAyC,uBAAzC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASV,KAAK,IAAIW,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,EAAmBC,wBAAnB,QAAmD,oBAAnD;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,eAApC;AACA,OAAOC,0BAAP,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AIC,IAAA,cAAc,EAAGK,WAAW,CAACc,MAAZ,GAAqB,CAJvC;AAKC,IAAA,MAAM,EAAGpB;AALV,IA7CF,EAqDG,CAAEuB,aAAF,IAAmB,CAAElB,UAArB,IACD,cAAC,OAAD,EAAciB,UAAd,EACC,cAAC,OAAD,OADD,CAtDF,EA0DGnB,2BAA2B,IAC5B,cAAC,KAAD;AACC,IAAA,gBAAgB,EAAC,6CADlB;AAEC,IAAA,KAAK,EAAGvB,OAAO,EACd;AACAD,IAAAA,EAAE,CAAE,aAAF,CAFY,EAGd0C,UAAU,CAACM,KAAX,CAAiBC,WAAjB,EAHc,CAFhB;AAOC,IAAA,UAAU,EAAGjD,EAAE,CAAE,QAAF,CAPhB;AAQC,IAAA,cAAc,EAAG,MAChByB,8BAA8B,CAAE,KAAF;AAThC,KAYC,cAAC,0BAAD;AACC,IAAA,cAAc,EAAGH,cADlB;AAEC,IAAA,QAAQ,EAAGN,QAFZ;AAGC,IAAA,IAAI,EAAGa,IAHR;AAIC,IAAA,aAAa,EAAGd,aAJjB;AAKC,IAAA,OAAO,EAAG,MACTU,8BAA8B,CAAE,KAAF;AANhC,IAZD,CA3DF,CADD;AAqFA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tBlockTitle,\n\tuseBlockProps,\n\tWarning,\n\tstore as blockEditorStore,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n} from '@wordpress/block-editor';\nimport { Spinner, Modal, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tisSelected,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst hasAlreadyRendered = useHasRecursion( templatePartId );\n\tconst [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =\n\t\tuseState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// The `isSelected` check ensures the `BlockSettingsMenuControls` fill\n\t// doesn't render multiple times. The block controls has similar internal check.\n\tconst canReplace =\n\t\tisSelected &&\n\t\tisEntityAvailable &&\n\t\thasReplacements &&\n\t\t( area === 'header' || area === 'footer' );\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ templatePartId }>\n\t\t\t<TemplatePartAdvancedControls\n\t\t\t\ttagName={ tagName }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t/>\n\t\t\t{ isPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ canReplace && (\n\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t__( 'Replace <BlockTitle />' ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tBlockTitle: (\n\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 25 }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\toverlayClassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["isEmpty","useSelect","BlockSettingsMenuControls","BlockTitle","useBlockProps","Warning","store","blockEditorStore","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Spinner","Modal","MenuItem","__","sprintf","coreStore","useState","createInterpolateElement","TemplatePartPlaceholder","TemplatePartSelectionModal","TemplatePartAdvancedControls","TemplatePartInnerBlocks","createTemplatePartId","useAlternativeBlockPatterns","useAlternativeTemplateParts","useTemplatePartArea","TemplatePartEdit","attributes","setAttributes","clientId","isSelected","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","getBlocks","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","canReplace","label","toLowerCase"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,yBADD,EAECC,UAFD,EAGCC,aAHD,EAICC,OAJD,EAKCC,KAAK,IAAIC,gBALV,EAMCC,+BAA+B,IAAIC,iBANpC,EAOCC,6BAA6B,IAAIC,eAPlC,QAQO,yBARP;AASA,SAASC,OAAT,EAAkBC,KAAlB,EAAyBC,QAAzB,QAAyC,uBAAzC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASV,KAAK,IAAIW,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,EAAmBC,wBAAnB,QAAmD,oBAAnD;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,eAApC;AACA,OAAOC,0BAAP,MAAuC,mBAAvC;AACA,SAASC,4BAAT,QAA6C,qBAA7C;AACA,OAAOC,uBAAP,MAAoC,gBAApC;AACA,SAASC,oBAAT,QAAqC,iCAArC;AACA,SACCC,2BADD,EAECC,2BAFD,EAGCC,mBAHD,QAIO,eAJP;AAMA,eAAe,SAASC,gBAAT,OAKX;AAAA,MALsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,aAFyC;AAGzCC,IAAAA,QAHyC;AAIzCC,IAAAA;AAJyC,GAKtC;AACH,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,MAAM,GAAG;AAAjC,MAAwCP,UAA9C;AACA,QAAMQ,cAAc,GAAGb,oBAAoB,CAAEU,KAAF,EAASD,IAAT,CAA3C;AACA,QAAMK,kBAAkB,GAAG3B,eAAe,CA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C,IAAA,cAAc,EAAGH,cADlB;AAEC,IAAA,QAAQ,EAAGN,QAFZ;AAGC,IAAA,IAAI,EAAGa,IAHR;AAIC,IAAA,aAAa,EAAGd,aAJjB;AAKC,IAAA,OAAO,EAAG,MACTU,8BAA8B,CAAE,KAAF;AANhC,IAZD,CA7DF,CADD;AAuFA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tBlockTitle,\n\tuseBlockProps,\n\tWarning,\n\tstore as blockEditorStore,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n} from '@wordpress/block-editor';\nimport { Spinner, Modal, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tisSelected,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst hasAlreadyRendered = useHasRecursion( templatePartId );\n\tconst [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =\n\t\tuseState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// The `isSelected` check ensures the `BlockSettingsMenuControls` fill\n\t// doesn't render multiple times. The block controls has similar internal check.\n\tconst canReplace =\n\t\tisSelected &&\n\t\tisEntityAvailable &&\n\t\thasReplacements &&\n\t\t( area === 'header' || area === 'footer' );\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RecursionProvider uniqueId={ templatePartId }>\n\t\t\t\t<TemplatePartAdvancedControls\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t\t/>\n\t\t\t\t{ isPlaceholder && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t\t{ canReplace && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__( 'Replace <BlockTitle />' ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tBlockTitle: (\n\t\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 25 }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t{ isEntityAvailable && (\n\t\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t</RecursionProvider>\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\toverlayClassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-button__link {
78
+ color: #fff;
79
+ background-color: #32373c;
80
+ border-radius: 9999px;
81
+ box-shadow: none;
82
+ text-decoration: none;
83
+ padding: calc(0.667em + 2px) calc(1.333em + 2px);
84
+ font-size: 1.125em;
85
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-button__link {
78
+ color: #fff;
79
+ background-color: #32373c;
80
+ border-radius: 9999px;
81
+ box-shadow: none;
82
+ text-decoration: none;
83
+ padding: calc(0.667em + 2px) calc(1.333em + 2px);
84
+ font-size: 1.125em;
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "7.14.1",
3
+ "version": "7.14.3",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,32 +31,32 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.17.0",
35
- "@wordpress/api-fetch": "^6.14.0",
36
- "@wordpress/autop": "^3.17.0",
37
- "@wordpress/blob": "^3.17.0",
38
- "@wordpress/block-editor": "^10.0.1",
39
- "@wordpress/blocks": "^11.16.1",
40
- "@wordpress/components": "^21.0.1",
41
- "@wordpress/compose": "^5.15.1",
42
- "@wordpress/core-data": "^5.0.1",
43
- "@wordpress/data": "^7.1.1",
44
- "@wordpress/date": "^4.17.0",
45
- "@wordpress/deprecated": "^3.17.0",
46
- "@wordpress/dom": "^3.17.1",
47
- "@wordpress/element": "^4.15.0",
48
- "@wordpress/hooks": "^3.17.0",
49
- "@wordpress/html-entities": "^3.17.0",
50
- "@wordpress/i18n": "^4.17.0",
51
- "@wordpress/icons": "^9.8.0",
52
- "@wordpress/keycodes": "^3.17.0",
53
- "@wordpress/notices": "^3.17.1",
54
- "@wordpress/primitives": "^3.15.0",
55
- "@wordpress/reusable-blocks": "^3.15.1",
56
- "@wordpress/rich-text": "^5.15.1",
57
- "@wordpress/server-side-render": "^3.15.1",
58
- "@wordpress/url": "^3.18.0",
59
- "@wordpress/viewport": "^4.15.1",
34
+ "@wordpress/a11y": "^3.17.1",
35
+ "@wordpress/api-fetch": "^6.14.1",
36
+ "@wordpress/autop": "^3.17.1",
37
+ "@wordpress/blob": "^3.17.1",
38
+ "@wordpress/block-editor": "^10.0.3",
39
+ "@wordpress/blocks": "^11.16.3",
40
+ "@wordpress/components": "^21.0.3",
41
+ "@wordpress/compose": "^5.15.2",
42
+ "@wordpress/core-data": "^5.0.3",
43
+ "@wordpress/data": "^7.1.2",
44
+ "@wordpress/date": "^4.17.1",
45
+ "@wordpress/deprecated": "^3.17.1",
46
+ "@wordpress/dom": "^3.17.2",
47
+ "@wordpress/element": "^4.15.1",
48
+ "@wordpress/hooks": "^3.17.1",
49
+ "@wordpress/html-entities": "^3.17.1",
50
+ "@wordpress/i18n": "^4.17.1",
51
+ "@wordpress/icons": "^9.8.1",
52
+ "@wordpress/keycodes": "^3.17.1",
53
+ "@wordpress/notices": "^3.17.2",
54
+ "@wordpress/primitives": "^3.15.1",
55
+ "@wordpress/reusable-blocks": "^3.15.3",
56
+ "@wordpress/rich-text": "^5.15.2",
57
+ "@wordpress/server-side-render": "^3.15.3",
58
+ "@wordpress/url": "^3.18.1",
59
+ "@wordpress/viewport": "^4.15.2",
60
60
  "change-case": "^4.1.2",
61
61
  "classnames": "^2.3.1",
62
62
  "colord": "^2.7.0",
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "access": "public"
75
75
  },
76
- "gitHead": "56ef3f5a754e44155ee79e827c7a1d0efc1ee5aa"
76
+ "gitHead": "54a676dba557a76062d3bf91bfe8a3e3ea12d254"
77
77
  }
@@ -0,0 +1,15 @@
1
+ // These rules are needed for backwards compatibility.
2
+ .wp-block-button__link {
3
+ color: $white;
4
+ background-color: #32373c;
5
+ border-radius: 9999px; // 100% causes an oval, but any explicit but really high value retains the pill shape.
6
+
7
+ // This needs a low specificity so it won't override the rules from the button element if defined in theme.json.
8
+ box-shadow: none;
9
+ text-decoration: none;
10
+
11
+ // The extra 2px are added to size solids the same as the outline versions.
12
+ padding: calc(0.667em + 2px) calc(1.333em + 2px);
13
+
14
+ font-size: 1.125em;
15
+ }
@@ -16,6 +16,8 @@
16
16
  */
17
17
  function block_core_comment_template_render_comments( $comments, $block ) {
18
18
  global $comment_depth;
19
+ $thread_comments = get_option( 'thread_comments' );
20
+ $thread_comments_depth = get_option( 'thread_comments_depth' );
19
21
 
20
22
  if ( empty( $comment_depth ) ) {
21
23
  $comment_depth = 1;
@@ -46,14 +48,22 @@ function block_core_comment_template_render_comments( $comments, $block ) {
46
48
 
47
49
  // If the comment has children, recurse to create the HTML for the nested
48
50
  // comments.
49
- if ( ! empty( $children ) ) {
50
- $comment_depth += 1;
51
- $inner_content = block_core_comment_template_render_comments(
52
- $children,
53
- $block
54
- );
55
- $block_content .= sprintf( '<ol>%1$s</ol>', $inner_content );
56
- $comment_depth -= 1;
51
+ if ( ! empty( $children ) && ! empty( $thread_comments ) ) {
52
+ if ( $comment_depth < $thread_comments_depth ) {
53
+ $comment_depth += 1;
54
+ $inner_content = block_core_comment_template_render_comments(
55
+ $children,
56
+ $block
57
+ );
58
+ $block_content .= sprintf( '<ol>%1$s</ol>', $inner_content );
59
+ $comment_depth -= 1;
60
+ } else {
61
+ $inner_content = block_core_comment_template_render_comments(
62
+ $children,
63
+ $block
64
+ );
65
+ $block_content .= sprintf( $inner_content );
66
+ }
57
67
  }
58
68
 
59
69
  $content .= sprintf( '<li id="comment-%1$s" %2$s>%3$s</li>', $comment->comment_ID, $comment_classes, $block_content );
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 2,
4
4
  "name": "core/comments-pagination-next",
5
- "title": "Next Page",
5
+ "title": "Comments Next Page",
6
6
  "category": "theme",
7
7
  "parent": [ "core/comments-pagination" ],
8
8
  "description": "Displays the next comment's page link.",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 2,
4
4
  "name": "core/comments-pagination-numbers",
5
- "title": "Page Numbers",
5
+ "title": "Comments Page Numbers",
6
6
  "category": "theme",
7
7
  "parent": [ "core/comments-pagination" ],
8
8
  "description": "Displays a list of page numbers for comments pagination.",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 2,
4
4
  "name": "core/comments-pagination-previous",
5
- "title": "Previous Page",
5
+ "title": "Comments Previous Page",
6
6
  "category": "theme",
7
7
  "parent": [ "core/comments-pagination" ],
8
8
  "description": "Displays the previous comment's page link.",