@wordpress/block-library 8.19.9 → 8.19.10

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 (32) hide show
  1. package/build/file/view.js +1 -1
  2. package/build/file/view.js.map +1 -1
  3. package/build/query/edit/enhanced-pagination-modal.js +4 -4
  4. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  5. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +9 -5
  6. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  7. package/build/query/utils.js +10 -8
  8. package/build/query/utils.js.map +1 -1
  9. package/build/term-description/index.js +0 -1
  10. package/build/term-description/index.js.map +1 -1
  11. package/build-module/file/view.js +2 -2
  12. package/build-module/file/view.js.map +1 -1
  13. package/build-module/query/edit/enhanced-pagination-modal.js +5 -5
  14. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  15. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +10 -6
  16. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  17. package/build-module/query/utils.js +8 -5
  18. package/build-module/query/utils.js.map +1 -1
  19. package/build-module/term-description/index.js +0 -1
  20. package/build-module/term-description/index.js.map +1 -1
  21. package/build-style/file/style-rtl.css +0 -5
  22. package/build-style/file/style.css +0 -5
  23. package/build-style/style-rtl.css +0 -5
  24. package/build-style/style.css +0 -5
  25. package/package.json +32 -32
  26. package/src/file/index.php +2 -1
  27. package/src/file/style.scss +0 -6
  28. package/src/file/view.js +2 -2
  29. package/src/query/edit/enhanced-pagination-modal.js +5 -5
  30. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +18 -9
  31. package/src/query/utils.js +14 -7
  32. package/src/term-description/block.json +0 -1
@@ -14,7 +14,7 @@ var _utils = require("./utils");
14
14
  selectors: {
15
15
  core: {
16
16
  file: {
17
- hasPdfPreview: (0, _utils.browserSupportsPdfs)() ? 'inherit' : 'none'
17
+ hasPdfPreview: _utils.browserSupportsPdfs
18
18
  }
19
19
  }
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_interactivity","require","_utils","store","selectors","core","file","hasPdfPreview","browserSupportsPdfs"],"sources":["@wordpress/block-library/src/file/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n/**\n * Internal dependencies\n */\nimport { browserSupportsPdfs } from './utils';\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tfile: {\n\t\t\t\thasPdfPreview: browserSupportsPdfs() ? 'inherit' : 'none',\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAPA;AACA;AACA;;AAEA;AACA;AACA;;AAGA,IAAAE,oBAAK,EAAE;EACNC,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,IAAI,EAAE;QACLC,aAAa,EAAE,IAAAC,0BAAmB,EAAC,CAAC,GAAG,SAAS,GAAG;MACpD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["_interactivity","require","_utils","store","selectors","core","file","hasPdfPreview"],"sources":["@wordpress/block-library/src/file/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n/**\n * Internal dependencies\n */\nimport { browserSupportsPdfs as hasPdfPreview } from './utils';\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tfile: {\n\t\t\t\thasPdfPreview,\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAPA;AACA;AACA;;AAEA;AACA;AACA;;AAGA,IAAAE,oBAAK,EAAE;EACNC,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,IAAI,EAAE;QACLC,aAAa,EAAbA;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -16,7 +16,7 @@ var _utils = require("../utils");
16
16
  * Internal dependencies
17
17
  */
18
18
 
19
- const disableEnhancedPaginationDescription = (0, _i18n.__)('Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable "Enhanced pagination" in the Query Block settings.');
19
+ const disableEnhancedPaginationDescription = (0, _i18n.__)('You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable "Enhanced pagination" in the Query Block settings.');
20
20
  const modalDescriptionId = 'wp-block-query-enhanced-pagination-modal__description';
21
21
  function EnhancedPaginationModal({
22
22
  clientId,
@@ -26,10 +26,10 @@ function EnhancedPaginationModal({
26
26
  setAttributes
27
27
  }) {
28
28
  const [isOpen, setOpen] = (0, _element.useState)(false);
29
- const containsThirdPartyBlocks = (0, _utils.useContainsThirdPartyBlocks)(clientId);
29
+ const unsupported = (0, _utils.useUnsupportedBlockList)(clientId);
30
30
  (0, _element.useEffect)(() => {
31
- setOpen(containsThirdPartyBlocks && enhancedPagination);
32
- }, [containsThirdPartyBlocks, enhancedPagination, setOpen]);
31
+ setOpen(!!unsupported.length && enhancedPagination);
32
+ }, [unsupported.length, enhancedPagination, setOpen]);
33
33
  return isOpen && (0, _element.createElement)(_components.Modal, {
34
34
  title: (0, _i18n.__)('Enhanced pagination will be disabled'),
35
35
  className: "wp-block-query__enhanced-pagination-modal",
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_components","_i18n","_utils","disableEnhancedPaginationDescription","__","modalDescriptionId","EnhancedPaginationModal","clientId","attributes","enhancedPagination","setAttributes","isOpen","setOpen","useState","containsThirdPartyBlocks","useContainsThirdPartyBlocks","useEffect","createElement","Modal","title","className","aria","describedby","isDismissible","shouldCloseOnEsc","shouldCloseOnClickOutside","__experimentalVStack","alignment","spacing","id","Button","variant","onClick"],"sources":["@wordpress/block-library/src/query/edit/enhanced-pagination-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useContainsThirdPartyBlocks } from '../utils';\n\nconst disableEnhancedPaginationDescription = __(\n\t'Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable \"Enhanced pagination\" in the Query Block settings.'\n);\n\nconst modalDescriptionId =\n\t'wp-block-query-enhanced-pagination-modal__description';\n\nexport default function EnhancedPaginationModal( {\n\tclientId,\n\tattributes: { enhancedPagination },\n\tsetAttributes,\n} ) {\n\tconst [ isOpen, setOpen ] = useState( false );\n\n\tconst containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );\n\n\tuseEffect( () => {\n\t\tsetOpen( containsThirdPartyBlocks && enhancedPagination );\n\t}, [ containsThirdPartyBlocks, enhancedPagination, setOpen ] );\n\n\treturn (\n\t\tisOpen && (\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Enhanced pagination will be disabled' ) }\n\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-modal\"\n\t\t\t\taria={ {\n\t\t\t\t\tdescribedby: modalDescriptionId,\n\t\t\t\t} }\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t>\n\t\t\t\t<VStack alignment=\"right\" spacing={ 5 }>\n\t\t\t\t\t<span id={ modalDescriptionId }>\n\t\t\t\t\t\t{ disableEnhancedPaginationDescription }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { enhancedPagination: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'OK' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t)\n\t);\n}\n"],"mappings":";;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,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ftB,aAAa,CAAE;QAAED,kBAAkB,EAAE;MAAM,CAAE,CAAC;IAC/C;EAAG,GAED,IAAAL,QAAE,EAAE,IAAK,CACJ,CACD,CACF,CACP;AAEH"}
1
+ {"version":3,"names":["_element","require","_components","_i18n","_utils","disableEnhancedPaginationDescription","__","modalDescriptionId","EnhancedPaginationModal","clientId","attributes","enhancedPagination","setAttributes","isOpen","setOpen","useState","unsupported","useUnsupportedBlockList","useEffect","length","createElement","Modal","title","className","aria","describedby","isDismissible","shouldCloseOnEsc","shouldCloseOnClickOutside","__experimentalVStack","alignment","spacing","id","Button","variant","onClick"],"sources":["@wordpress/block-library/src/query/edit/enhanced-pagination-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useUnsupportedBlockList } from '../utils';\n\nconst disableEnhancedPaginationDescription = __(\n\t'You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable \"Enhanced pagination\" in the Query Block settings.'\n);\n\nconst modalDescriptionId =\n\t'wp-block-query-enhanced-pagination-modal__description';\n\nexport default function EnhancedPaginationModal( {\n\tclientId,\n\tattributes: { enhancedPagination },\n\tsetAttributes,\n} ) {\n\tconst [ isOpen, setOpen ] = useState( false );\n\n\tconst unsupported = useUnsupportedBlockList( clientId );\n\n\tuseEffect( () => {\n\t\tsetOpen( !! unsupported.length && enhancedPagination );\n\t}, [ unsupported.length, enhancedPagination, setOpen ] );\n\n\treturn (\n\t\tisOpen && (\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Enhanced pagination will be disabled' ) }\n\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-modal\"\n\t\t\t\taria={ {\n\t\t\t\t\tdescribedby: modalDescriptionId,\n\t\t\t\t} }\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t>\n\t\t\t\t<VStack alignment=\"right\" spacing={ 5 }>\n\t\t\t\t\t<span id={ modalDescriptionId }>\n\t\t\t\t\t\t{ disableEnhancedPaginationDescription }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { enhancedPagination: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'OK' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t)\n\t);\n}\n"],"mappings":";;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AAdA;AACA;AACA;;AASA;AACA;AACA;;AAGA,MAAMI,oCAAoC,GAAG,IAAAC,QAAE,EAC9C,wJACD,CAAC;AAED,MAAMC,kBAAkB,GACvB,uDAAuD;AAEzC,SAASC,uBAAuBA,CAAE;EAChDC,QAAQ;EACRC,UAAU,EAAE;IAAEC;EAAmB,CAAC;EAClCC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,MAAM,EAAEC,OAAO,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAE7C,MAAMC,WAAW,GAAG,IAAAC,8BAAuB,EAAER,QAAS,CAAC;EAEvD,IAAAS,kBAAS,EAAE,MAAM;IAChBJ,OAAO,CAAE,CAAC,CAAEE,WAAW,CAACG,MAAM,IAAIR,kBAAmB,CAAC;EACvD,CAAC,EAAE,CAAEK,WAAW,CAACG,MAAM,EAAER,kBAAkB,EAAEG,OAAO,CAAG,CAAC;EAExD,OACCD,MAAM,IACL,IAAAb,QAAA,CAAAoB,aAAA,EAAClB,WAAA,CAAAmB,KAAK;IACLC,KAAK,EAAG,IAAAhB,QAAE,EAAE,sCAAuC,CAAG;IACtDiB,SAAS,EAAC,2CAA2C;IACrDC,IAAI,EAAG;MACNC,WAAW,EAAElB;IACd,CAAG;IACHmB,aAAa,EAAG,KAAO;IACvBC,gBAAgB,EAAG,KAAO;IAC1BC,yBAAyB,EAAG;EAAO,GAEnC,IAAA5B,QAAA,CAAAoB,aAAA,EAAClB,WAAA,CAAA2B,oBAAM;IAACC,SAAS,EAAC,OAAO;IAACC,OAAO,EAAG;EAAG,GACtC,IAAA/B,QAAA,CAAAoB,aAAA;IAAMY,EAAE,EAAGzB;EAAoB,GAC5BF,oCACG,CAAC,EACP,IAAAL,QAAA,CAAAoB,aAAA,EAAClB,WAAA,CAAA+B,MAAM;IACNC,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAGA,CAAA,KAAM;MACfvB,aAAa,CAAE;QAAED,kBAAkB,EAAE;MAAM,CAAE,CAAC;IAC/C;EAAG,GAED,IAAAL,QAAE,EAAE,IAAK,CACJ,CACD,CACF,CACP;AAEH"}
@@ -7,6 +7,7 @@ exports.default = EnhancedPaginationControl;
7
7
  var _element = require("@wordpress/element");
8
8
  var _components = require("@wordpress/components");
9
9
  var _i18n = require("@wordpress/i18n");
10
+ var _blockEditor = require("@wordpress/block-editor");
10
11
  var _utils = require("../../utils");
11
12
  /**
12
13
  * WordPress dependencies
@@ -21,22 +22,25 @@ function EnhancedPaginationControl({
21
22
  setAttributes,
22
23
  clientId
23
24
  }) {
24
- const enhancedPaginationNotice = (0, _i18n.__)("Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop.");
25
- const containsThirdPartyBlocks = (0, _utils.useContainsThirdPartyBlocks)(clientId);
25
+ const unsupported = (0, _utils.useUnsupportedBlockList)(clientId);
26
26
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.ToggleControl, {
27
27
  label: (0, _i18n.__)('Enhanced pagination'),
28
28
  help: (0, _i18n.__)('Browsing between pages won’t require a full page reload.'),
29
29
  checked: !!enhancedPagination,
30
- disabled: containsThirdPartyBlocks,
30
+ disabled: unsupported.length,
31
31
  onChange: value => {
32
32
  setAttributes({
33
33
  enhancedPagination: !!value
34
34
  });
35
35
  }
36
- }), containsThirdPartyBlocks && (0, _element.createElement)(_components.Notice, {
36
+ }), !!unsupported.length && (0, _element.createElement)(_components.Notice, {
37
37
  status: "warning",
38
38
  isDismissible: false,
39
39
  className: "wp-block-query__enhanced-pagination-notice"
40
- }, enhancedPaginationNotice));
40
+ }, (0, _i18n.__)("Enhanced pagination doesn't support the following blocks:"), (0, _element.createElement)("ul", null, unsupported.map(id => (0, _element.createElement)("li", {
41
+ key: id
42
+ }, (0, _element.createElement)(_blockEditor.BlockTitle, {
43
+ clientId: id
44
+ })))), (0, _i18n.__)('If you want to enable it, you have to remove all unsupported blocks first.')));
41
45
  }
42
46
  //# sourceMappingURL=enhanced-pagination-control.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_utils","EnhancedPaginationControl","enhancedPagination","setAttributes","clientId","enhancedPaginationNotice","__","containsThirdPartyBlocks","useContainsThirdPartyBlocks","_element","createElement","Fragment","ToggleControl","label","help","checked","disabled","onChange","value","Notice","status","isDismissible","className"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/enhanced-pagination-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContainsThirdPartyBlocks } from '../../utils';\n\nexport default function EnhancedPaginationControl( {\n\tenhancedPagination,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst enhancedPaginationNotice = __(\n\t\t\"Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop.\"\n\t);\n\n\tconst containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Browsing between pages won’t require a full page reload.'\n\t\t\t\t) }\n\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\tdisabled={ containsThirdPartyBlocks }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ containsThirdPartyBlocks && (\n\t\t\t\t<Notice\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-notice\"\n\t\t\t\t>\n\t\t\t\t\t{ enhancedPaginationNotice }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASG,yBAAyBA,CAAE;EAClDC,kBAAkB;EAClBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,wBAAwB,GAAG,IAAAC,QAAE,EAClC,4IACD,CAAC;EAED,MAAMC,wBAAwB,GAAG,IAAAC,kCAA2B,EAAEJ,QAAS,CAAC;EAExE,OACC,IAAAK,QAAA,CAAAC,aAAA,EAAAD,QAAA,CAAAE,QAAA,QACC,IAAAF,QAAA,CAAAC,aAAA,EAACb,WAAA,CAAAe,aAAa;IACbC,KAAK,EAAG,IAAAP,QAAE,EAAE,qBAAsB,CAAG;IACrCQ,IAAI,EAAG,IAAAR,QAAE,EACR,0DACD,CAAG;IACHS,OAAO,EAAG,CAAC,CAAEb,kBAAoB;IACjCc,QAAQ,EAAGT,wBAA0B;IACrCU,QAAQ,EAAKC,KAAK,IAAM;MACvBf,aAAa,CAAE;QACdD,kBAAkB,EAAE,CAAC,CAAEgB;MACxB,CAAE,CAAC;IACJ;EAAG,CACH,CAAC,EACAX,wBAAwB,IACzB,IAAAE,QAAA,CAAAC,aAAA,EAACb,WAAA,CAAAsB,MAAM;IACNC,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG,KAAO;IACvBC,SAAS,EAAC;EAA4C,GAEpDjB,wBACK,CAER,CAAC;AAEL"}
1
+ {"version":3,"names":["_components","require","_i18n","_blockEditor","_utils","EnhancedPaginationControl","enhancedPagination","setAttributes","clientId","unsupported","useUnsupportedBlockList","_element","createElement","Fragment","ToggleControl","label","__","help","checked","disabled","length","onChange","value","Notice","status","isDismissible","className","map","id","key","BlockTitle"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/enhanced-pagination-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { BlockTitle } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useUnsupportedBlockList } from '../../utils';\n\nexport default function EnhancedPaginationControl( {\n\tenhancedPagination,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst unsupported = useUnsupportedBlockList( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Browsing between pages won’t require a full page reload.'\n\t\t\t\t) }\n\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\tdisabled={ unsupported.length }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ !! unsupported.length && (\n\t\t\t\t<Notice\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-notice\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t\"Enhanced pagination doesn't support the following blocks:\"\n\t\t\t\t\t) }\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{ unsupported.map( ( id ) => (\n\t\t\t\t\t\t\t<li key={ id }>\n\t\t\t\t\t\t\t\t<BlockTitle clientId={ id } />\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'If you want to enable it, you have to remove all unsupported blocks first.'\n\t\t\t\t\t) }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGe,SAASI,yBAAyBA,CAAE;EAClDC,kBAAkB;EAClBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,WAAW,GAAG,IAAAC,8BAAuB,EAAEF,QAAS,CAAC;EAEvD,OACC,IAAAG,QAAA,CAAAC,aAAA,EAAAD,QAAA,CAAAE,QAAA,QACC,IAAAF,QAAA,CAAAC,aAAA,EAACZ,WAAA,CAAAc,aAAa;IACbC,KAAK,EAAG,IAAAC,QAAE,EAAE,qBAAsB,CAAG;IACrCC,IAAI,EAAG,IAAAD,QAAE,EACR,0DACD,CAAG;IACHE,OAAO,EAAG,CAAC,CAAEZ,kBAAoB;IACjCa,QAAQ,EAAGV,WAAW,CAACW,MAAQ;IAC/BC,QAAQ,EAAKC,KAAK,IAAM;MACvBf,aAAa,CAAE;QACdD,kBAAkB,EAAE,CAAC,CAAEgB;MACxB,CAAE,CAAC;IACJ;EAAG,CACH,CAAC,EACA,CAAC,CAAEb,WAAW,CAACW,MAAM,IACtB,IAAAT,QAAA,CAAAC,aAAA,EAACZ,WAAA,CAAAuB,MAAM;IACNC,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG,KAAO;IACvBC,SAAS,EAAC;EAA4C,GAEpD,IAAAV,QAAE,EACH,2DACD,CAAC,EACD,IAAAL,QAAA,CAAAC,aAAA,cACGH,WAAW,CAACkB,GAAG,CAAIC,EAAE,IACtB,IAAAjB,QAAA,CAAAC,aAAA;IAAIiB,GAAG,EAAGD;EAAI,GACb,IAAAjB,QAAA,CAAAC,aAAA,EAACT,YAAA,CAAA2B,UAAU;IAACtB,QAAQ,EAAGoB;EAAI,CAAE,CAC1B,CACH,CACC,CAAC,EACH,IAAAZ,QAAE,EACH,4EACD,CACO,CAER,CAAC;AAEL"}
@@ -8,11 +8,10 @@ exports.isControlAllowed = isControlAllowed;
8
8
  exports.mapToIHasNameAndId = void 0;
9
9
  exports.useAllowedControls = useAllowedControls;
10
10
  exports.useBlockNameForPatterns = useBlockNameForPatterns;
11
- exports.useContainsThirdPartyBlocks = void 0;
12
11
  exports.useIsPostTypeHierarchical = useIsPostTypeHierarchical;
13
12
  exports.usePostTypes = exports.usePatterns = void 0;
14
13
  exports.useScopedBlockVariations = useScopedBlockVariations;
15
- exports.useTaxonomies = void 0;
14
+ exports.useUnsupportedBlockList = exports.useTaxonomies = void 0;
16
15
  var _data = require("@wordpress/data");
17
16
  var _element = require("@wordpress/element");
18
17
  var _coreData = require("@wordpress/core-data");
@@ -353,21 +352,24 @@ const usePatterns = (clientId, name) => {
353
352
  };
354
353
 
355
354
  /**
356
- * Hook that returns whether the Query Loop with the given `clientId` contains
357
- * any third-party block.
355
+ * Hook that returns a list of unsupported blocks inside the Query Loop with the
356
+ * given `clientId`.
358
357
  *
359
358
  * @param {string} clientId The block's client ID.
360
- * @return {boolean} True if it contains third-party blocks.
359
+ * @return {string[]} List of block titles.
361
360
  */
362
361
  exports.usePatterns = usePatterns;
363
- const useContainsThirdPartyBlocks = clientId => {
362
+ const useUnsupportedBlockList = clientId => {
364
363
  return (0, _data.useSelect)(select => {
365
364
  const {
366
365
  getClientIdsOfDescendants,
367
366
  getBlockName
368
367
  } = select(_blockEditor.store);
369
- return getClientIdsOfDescendants(clientId).some(descendantClientId => !getBlockName(descendantClientId).startsWith('core/'));
368
+ return getClientIdsOfDescendants(clientId).filter(descendantClientId => {
369
+ const blockName = getBlockName(descendantClientId);
370
+ return !blockName.startsWith('core/') || blockName === 'core/post-content' || blockName === 'core/template-part' || blockName === 'core/block';
371
+ });
370
372
  }, [clientId]);
371
373
  };
372
- exports.useContainsThirdPartyBlocks = useContainsThirdPartyBlocks;
374
+ exports.useUnsupportedBlockList = useUnsupportedBlockList;
373
375
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_blockEditor","_htmlEntities","_blocks","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","exports","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","decodeEntities","usePostTypes","postTypes","useSelect","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","useMemo","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","cloneBlock","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","blockEditorStore","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useContainsThirdPartyBlocks","getClientIdsOfDescendants","getBlockName","some","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = 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\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns whether the Query Loop with the given `clientId` contains\n * any third-party block.\n *\n * @param {string} clientId The block's client ID.\n * @return {boolean} True if it contains third-party blocks.\n */\nexport const useContainsThirdPartyBlocks = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).some(\n\t\t\t\t( descendantClientId ) =>\n\t\t\t\t\t! getBlockName( descendantClientId ).startsWith( 'core/' )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAC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D,kBAAiB,CAAC;IAE3B,OAAOa,yBAAyB,CAAEvB,QAAS,CAAC,CAACyB,IAAI,CAC9CC,kBAAkB,IACnB,CAAEF,YAAY,CAAEE,kBAAmB,CAAC,CAACC,UAAU,CAAE,OAAQ,CAC3D,CAAC;EACF,CAAC,EACD,CAAE3B,QAAQ,CACX,CAAC;AACF,CAAC;AAAC5D,OAAA,CAAAkF,2BAAA,GAAAA,2BAAA"}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_blockEditor","_htmlEntities","_blocks","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","exports","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","decodeEntities","usePostTypes","postTypes","useSelect","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","useMemo","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","cloneBlock","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","blockEditorStore","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useUnsupportedBlockList","getClientIdsOfDescendants","getBlockName","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = 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\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns a list of unsupported blocks inside the Query Loop with the\n * given `clientId`.\n *\n * @param {string} clientId The block's client ID.\n * @return {string[]} List of block titles.\n */\nexport const useUnsupportedBlockList = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).filter(\n\t\t\t\t( descendantClientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( descendantClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! blockName.startsWith( 'core/' ) ||\n\t\t\t\t\t\tblockName === 'core/post-content' ||\n\t\t\t\t\t\tblockName === 'core/template-part' ||\n\t\t\t\t\t\tblockName === 'core/block'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;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BAAiB,CAAC;IAE3B,OAAOa,yBAAyB,CAAEvB,QAAS,CAAC,CAACvC,MAAM,CAChDgE,kBAAkB,IAAM;MACzB,MAAMnB,SAAS,GAAGkB,YAAY,CAAEC,kBAAmB,CAAC;MACpD,OACC,CAAEnB,SAAS,CAACoB,UAAU,CAAE,OAAQ,CAAC,IACjCpB,SAAS,KAAK,mBAAmB,IACjCA,SAAS,KAAK,oBAAoB,IAClCA,SAAS,KAAK,YAAY;IAE5B,CACD,CAAC;EACF,CAAC,EACD,CAAEN,QAAQ,CACX,CAAC;AACF,CAAC;AAAC5D,OAAA,CAAAkF,uBAAA,GAAAA,uBAAA"}
@@ -17,7 +17,6 @@ var _edit = _interopRequireDefault(require("./edit"));
17
17
  const metadata = {
18
18
  $schema: "https://schemas.wp.org/trunk/block.json",
19
19
  apiVersion: 3,
20
- __experimental: "fse",
21
20
  name: "core/term-description",
22
21
  title: "Term Description",
23
22
  category: "theme",
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","metadata","$schema","apiVersion","__experimental","name","title","category","description","textdomain","attributes","textAlign","type","supports","align","html","color","link","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","exports","settings","icon","edit","init","initBlock"],"sources":["@wordpress/block-library/src/term-description/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAI,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;AAAA;AAAAQ,OAAA,CAAAhC,QAAA,GAAAA,QAAA;AAOA,MAAM;EAAEI;AAAK,CAAC,GAAGJ,QAAQ;AAACgC,OAAA,CAAA5B,IAAA,GAAAA,IAAA;AAGnB,MAAM6B,QAAQ,GAAG;EACvBC,IAAI,EAAJA,sBAAI;EACJC,IAAI,EAAJA;AACD,CAAC;AAACH,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMG,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAEjC,IAAI;EAAEJ,QAAQ;EAAEiC;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAI,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","textAlign","type","supports","align","html","color","link","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","exports","settings","icon","edit","init","initBlock"],"sources":["@wordpress/block-library/src/term-description/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAI,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;AAAA;AAAAQ,OAAA,CAAA/B,QAAA,GAAAA,QAAA;AAOA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAAC+B,OAAA,CAAA5B,IAAA,GAAAA,IAAA;AAGnB,MAAM6B,QAAQ,GAAG;EACvBC,IAAI,EAAJA,sBAAI;EACJC,IAAI,EAAJA;AACD,CAAC;AAACH,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMG,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAEjC,IAAI;EAAEH,QAAQ;EAAEgC;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAI,IAAA,GAAAA,IAAA"}
@@ -5,12 +5,12 @@ import { store } from '@wordpress/interactivity';
5
5
  /**
6
6
  * Internal dependencies
7
7
  */
8
- import { browserSupportsPdfs } from './utils';
8
+ import { browserSupportsPdfs as hasPdfPreview } from './utils';
9
9
  store({
10
10
  selectors: {
11
11
  core: {
12
12
  file: {
13
- hasPdfPreview: browserSupportsPdfs() ? 'inherit' : 'none'
13
+ hasPdfPreview
14
14
  }
15
15
  }
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"names":["store","browserSupportsPdfs","selectors","core","file","hasPdfPreview"],"sources":["@wordpress/block-library/src/file/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n/**\n * Internal dependencies\n */\nimport { browserSupportsPdfs } from './utils';\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tfile: {\n\t\t\t\thasPdfPreview: browserSupportsPdfs() ? 'inherit' : 'none',\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAChD;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,SAAS;AAE7CD,KAAK,CAAE;EACNE,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,IAAI,EAAE;QACLC,aAAa,EAAEJ,mBAAmB,CAAC,CAAC,GAAG,SAAS,GAAG;MACpD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["store","browserSupportsPdfs","hasPdfPreview","selectors","core","file"],"sources":["@wordpress/block-library/src/file/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n/**\n * Internal dependencies\n */\nimport { browserSupportsPdfs as hasPdfPreview } from './utils';\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tfile: {\n\t\t\t\thasPdfPreview,\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAChD;AACA;AACA;AACA,SAASC,mBAAmB,IAAIC,aAAa,QAAQ,SAAS;AAE9DF,KAAK,CAAE;EACNG,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,IAAI,EAAE;QACLH;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -9,8 +9,8 @@ import { useState, useEffect } from '@wordpress/element';
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import { useContainsThirdPartyBlocks } from '../utils';
13
- const disableEnhancedPaginationDescription = __('Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable "Enhanced pagination" in the Query Block settings.');
12
+ import { useUnsupportedBlockList } from '../utils';
13
+ const disableEnhancedPaginationDescription = __('You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable "Enhanced pagination" in the Query Block settings.');
14
14
  const modalDescriptionId = 'wp-block-query-enhanced-pagination-modal__description';
15
15
  export default function EnhancedPaginationModal({
16
16
  clientId,
@@ -20,10 +20,10 @@ export default function EnhancedPaginationModal({
20
20
  setAttributes
21
21
  }) {
22
22
  const [isOpen, setOpen] = useState(false);
23
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks(clientId);
23
+ const unsupported = useUnsupportedBlockList(clientId);
24
24
  useEffect(() => {
25
- setOpen(containsThirdPartyBlocks && enhancedPagination);
26
- }, [containsThirdPartyBlocks, enhancedPagination, setOpen]);
25
+ setOpen(!!unsupported.length && enhancedPagination);
26
+ }, [unsupported.length, enhancedPagination, setOpen]);
27
27
  return isOpen && createElement(Modal, {
28
28
  title: __('Enhanced pagination will be disabled'),
29
29
  className: "wp-block-query__enhanced-pagination-modal",
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Modal","__experimentalVStack","VStack","__","useState","useEffect","useContainsThirdPartyBlocks","disableEnhancedPaginationDescription","modalDescriptionId","EnhancedPaginationModal","clientId","attributes","enhancedPagination","setAttributes","isOpen","setOpen","containsThirdPartyBlocks","createElement","title","className","aria","describedby","isDismissible","shouldCloseOnEsc","shouldCloseOnClickOutside","alignment","spacing","id","variant","onClick"],"sources":["@wordpress/block-library/src/query/edit/enhanced-pagination-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useContainsThirdPartyBlocks } from '../utils';\n\nconst disableEnhancedPaginationDescription = __(\n\t'Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable \"Enhanced pagination\" in the Query Block settings.'\n);\n\nconst modalDescriptionId =\n\t'wp-block-query-enhanced-pagination-modal__description';\n\nexport default function EnhancedPaginationModal( {\n\tclientId,\n\tattributes: { enhancedPagination },\n\tsetAttributes,\n} ) {\n\tconst [ isOpen, setOpen ] = useState( false );\n\n\tconst containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );\n\n\tuseEffect( () => {\n\t\tsetOpen( containsThirdPartyBlocks && enhancedPagination );\n\t}, [ containsThirdPartyBlocks, enhancedPagination, setOpen ] );\n\n\treturn (\n\t\tisOpen && (\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Enhanced pagination will be disabled' ) }\n\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-modal\"\n\t\t\t\taria={ {\n\t\t\t\t\tdescribedby: modalDescriptionId,\n\t\t\t\t} }\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t>\n\t\t\t\t<VStack alignment=\"right\" spacing={ 5 }>\n\t\t\t\t\t<span id={ modalDescriptionId }>\n\t\t\t\t\t\t{ disableEnhancedPaginationDescription }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { enhancedPagination: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'OK' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t)\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA,SAASC,2BAA2B,QAAQ,UAAU;AAEtD,MAAMC,oCAAoC,GAAGJ,EAAE,CAC9C,sKACD,CAAC;AAED,MAAMK,kBAAkB,GACvB,uDAAuD;AAExD,eAAe,SAASC,uBAAuBA,CAAE;EAChDC,QAAQ;EACRC,UAAU,EAAE;IAAEC;EAAmB,CAAC;EAClCC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,MAAM,EAAEC,OAAO,CAAE,GAAGX,QAAQ,CAAE,KAAM,CAAC;EAE7C,MAAMY,wBAAwB,GAAGV,2BAA2B,CAAEI,QAAS,CAAC;EAExEL,SAAS,CAAE,MAAM;IAChBU,OAAO,CAAEC,wBAAwB,IAAIJ,kBAAmB,CAAC;EAC1D,CAAC,EAAE,CAAEI,wBAAwB,EAAEJ,kBAAkB,EAAEG,OAAO,CAAG,CAAC;EAE9D,OACCD,MAAM,IACLG,aAAA,CAACjB,KAAK;IACLkB,KAAK,EAAGf,EAAE,CAAE,sCAAuC,CAAG;IACtDgB,SAAS,EAAC,2CAA2C;IACrDC,IAAI,EAAG;MACNC,WAAW,EAAEb;IACd,CAAG;IACHc,aAAa,EAAG,KAAO;IACvBC,gBAAgB,EAAG,KAAO;IAC1BC,yBAAyB,EAAG;EAAO,GAEnCP,aAAA,CAACf,MAAM;IAACuB,SAAS,EAAC,OAAO;IAACC,OAAO,EAAG;EAAG,GACtCT,aAAA;IAAMU,EAAE,EAAGnB;EAAoB,GAC5BD,oCACG,CAAC,EACPU,aAAA,CAAClB,MAAM;IACN6B,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAGA,CAAA,KAAM;MACfhB,aAAa,CAAE;QAAED,kBAAkB,EAAE;MAAM,CAAE,CAAC;IAC/C;EAAG,GAEDT,EAAE,CAAE,IAAK,CACJ,CACD,CACF,CACP;AAEH"}
1
+ {"version":3,"names":["Button","Modal","__experimentalVStack","VStack","__","useState","useEffect","useUnsupportedBlockList","disableEnhancedPaginationDescription","modalDescriptionId","EnhancedPaginationModal","clientId","attributes","enhancedPagination","setAttributes","isOpen","setOpen","unsupported","length","createElement","title","className","aria","describedby","isDismissible","shouldCloseOnEsc","shouldCloseOnClickOutside","alignment","spacing","id","variant","onClick"],"sources":["@wordpress/block-library/src/query/edit/enhanced-pagination-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useUnsupportedBlockList } from '../utils';\n\nconst disableEnhancedPaginationDescription = __(\n\t'You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable \"Enhanced pagination\" in the Query Block settings.'\n);\n\nconst modalDescriptionId =\n\t'wp-block-query-enhanced-pagination-modal__description';\n\nexport default function EnhancedPaginationModal( {\n\tclientId,\n\tattributes: { enhancedPagination },\n\tsetAttributes,\n} ) {\n\tconst [ isOpen, setOpen ] = useState( false );\n\n\tconst unsupported = useUnsupportedBlockList( clientId );\n\n\tuseEffect( () => {\n\t\tsetOpen( !! unsupported.length && enhancedPagination );\n\t}, [ unsupported.length, enhancedPagination, setOpen ] );\n\n\treturn (\n\t\tisOpen && (\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Enhanced pagination will be disabled' ) }\n\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-modal\"\n\t\t\t\taria={ {\n\t\t\t\t\tdescribedby: modalDescriptionId,\n\t\t\t\t} }\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t>\n\t\t\t\t<VStack alignment=\"right\" spacing={ 5 }>\n\t\t\t\t\t<span id={ modalDescriptionId }>\n\t\t\t\t\t\t{ disableEnhancedPaginationDescription }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { enhancedPagination: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'OK' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t)\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,UAAU;AAElD,MAAMC,oCAAoC,GAAGJ,EAAE,CAC9C,wJACD,CAAC;AAED,MAAMK,kBAAkB,GACvB,uDAAuD;AAExD,eAAe,SAASC,uBAAuBA,CAAE;EAChDC,QAAQ;EACRC,UAAU,EAAE;IAAEC;EAAmB,CAAC;EAClCC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,MAAM,EAAEC,OAAO,CAAE,GAAGX,QAAQ,CAAE,KAAM,CAAC;EAE7C,MAAMY,WAAW,GAAGV,uBAAuB,CAAEI,QAAS,CAAC;EAEvDL,SAAS,CAAE,MAAM;IAChBU,OAAO,CAAE,CAAC,CAAEC,WAAW,CAACC,MAAM,IAAIL,kBAAmB,CAAC;EACvD,CAAC,EAAE,CAAEI,WAAW,CAACC,MAAM,EAAEL,kBAAkB,EAAEG,OAAO,CAAG,CAAC;EAExD,OACCD,MAAM,IACLI,aAAA,CAAClB,KAAK;IACLmB,KAAK,EAAGhB,EAAE,CAAE,sCAAuC,CAAG;IACtDiB,SAAS,EAAC,2CAA2C;IACrDC,IAAI,EAAG;MACNC,WAAW,EAAEd;IACd,CAAG;IACHe,aAAa,EAAG,KAAO;IACvBC,gBAAgB,EAAG,KAAO;IAC1BC,yBAAyB,EAAG;EAAO,GAEnCP,aAAA,CAAChB,MAAM;IAACwB,SAAS,EAAC,OAAO;IAACC,OAAO,EAAG;EAAG,GACtCT,aAAA;IAAMU,EAAE,EAAGpB;EAAoB,GAC5BD,oCACG,CAAC,EACPW,aAAA,CAACnB,MAAM;IACN8B,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAGA,CAAA,KAAM;MACfjB,aAAa,CAAE;QAAED,kBAAkB,EAAE;MAAM,CAAE,CAAC;IAC/C;EAAG,GAEDT,EAAE,CAAE,IAAK,CACJ,CACD,CACF,CACP;AAEH"}
@@ -4,32 +4,36 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  */
5
5
  import { ToggleControl, Notice } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
+ import { BlockTitle } from '@wordpress/block-editor';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
- import { useContainsThirdPartyBlocks } from '../../utils';
12
+ import { useUnsupportedBlockList } from '../../utils';
12
13
  export default function EnhancedPaginationControl({
13
14
  enhancedPagination,
14
15
  setAttributes,
15
16
  clientId
16
17
  }) {
17
- const enhancedPaginationNotice = __("Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop.");
18
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks(clientId);
18
+ const unsupported = useUnsupportedBlockList(clientId);
19
19
  return createElement(Fragment, null, createElement(ToggleControl, {
20
20
  label: __('Enhanced pagination'),
21
21
  help: __('Browsing between pages won’t require a full page reload.'),
22
22
  checked: !!enhancedPagination,
23
- disabled: containsThirdPartyBlocks,
23
+ disabled: unsupported.length,
24
24
  onChange: value => {
25
25
  setAttributes({
26
26
  enhancedPagination: !!value
27
27
  });
28
28
  }
29
- }), containsThirdPartyBlocks && createElement(Notice, {
29
+ }), !!unsupported.length && createElement(Notice, {
30
30
  status: "warning",
31
31
  isDismissible: false,
32
32
  className: "wp-block-query__enhanced-pagination-notice"
33
- }, enhancedPaginationNotice));
33
+ }, __("Enhanced pagination doesn't support the following blocks:"), createElement("ul", null, unsupported.map(id => createElement("li", {
34
+ key: id
35
+ }, createElement(BlockTitle, {
36
+ clientId: id
37
+ })))), __('If you want to enable it, you have to remove all unsupported blocks first.')));
34
38
  }
35
39
  //# sourceMappingURL=enhanced-pagination-control.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ToggleControl","Notice","__","useContainsThirdPartyBlocks","EnhancedPaginationControl","enhancedPagination","setAttributes","clientId","enhancedPaginationNotice","containsThirdPartyBlocks","createElement","Fragment","label","help","checked","disabled","onChange","value","status","isDismissible","className"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/enhanced-pagination-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContainsThirdPartyBlocks } from '../../utils';\n\nexport default function EnhancedPaginationControl( {\n\tenhancedPagination,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst enhancedPaginationNotice = __(\n\t\t\"Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop.\"\n\t);\n\n\tconst containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Browsing between pages won’t require a full page reload.'\n\t\t\t\t) }\n\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\tdisabled={ containsThirdPartyBlocks }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ containsThirdPartyBlocks && (\n\t\t\t\t<Notice\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-notice\"\n\t\t\t\t>\n\t\t\t\t\t{ enhancedPaginationNotice }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,MAAM,QAAQ,uBAAuB;AAC7D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,2BAA2B,QAAQ,aAAa;AAEzD,eAAe,SAASC,yBAAyBA,CAAE;EAClDC,kBAAkB;EAClBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,wBAAwB,GAAGN,EAAE,CAClC,4IACD,CAAC;EAED,MAAMO,wBAAwB,GAAGN,2BAA2B,CAAEI,QAAS,CAAC;EAExE,OACCG,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACV,aAAa;IACbY,KAAK,EAAGV,EAAE,CAAE,qBAAsB,CAAG;IACrCW,IAAI,EAAGX,EAAE,CACR,0DACD,CAAG;IACHY,OAAO,EAAG,CAAC,CAAET,kBAAoB;IACjCU,QAAQ,EAAGN,wBAA0B;IACrCO,QAAQ,EAAKC,KAAK,IAAM;MACvBX,aAAa,CAAE;QACdD,kBAAkB,EAAE,CAAC,CAAEY;MACxB,CAAE,CAAC;IACJ;EAAG,CACH,CAAC,EACAR,wBAAwB,IACzBC,aAAA,CAACT,MAAM;IACNiB,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG,KAAO;IACvBC,SAAS,EAAC;EAA4C,GAEpDZ,wBACK,CAER,CAAC;AAEL"}
1
+ {"version":3,"names":["ToggleControl","Notice","__","BlockTitle","useUnsupportedBlockList","EnhancedPaginationControl","enhancedPagination","setAttributes","clientId","unsupported","createElement","Fragment","label","help","checked","disabled","length","onChange","value","status","isDismissible","className","map","id","key"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/enhanced-pagination-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { BlockTitle } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useUnsupportedBlockList } from '../../utils';\n\nexport default function EnhancedPaginationControl( {\n\tenhancedPagination,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst unsupported = useUnsupportedBlockList( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Browsing between pages won’t require a full page reload.'\n\t\t\t\t) }\n\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\tdisabled={ unsupported.length }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ !! unsupported.length && (\n\t\t\t\t<Notice\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-notice\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t\"Enhanced pagination doesn't support the following blocks:\"\n\t\t\t\t\t) }\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{ unsupported.map( ( id ) => (\n\t\t\t\t\t\t\t<li key={ id }>\n\t\t\t\t\t\t\t\t<BlockTitle clientId={ id } />\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'If you want to enable it, you have to remove all unsupported blocks first.'\n\t\t\t\t\t) }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,MAAM,QAAQ,uBAAuB;AAC7D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,yBAAyB;;AAEpD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,aAAa;AAErD,eAAe,SAASC,yBAAyBA,CAAE;EAClDC,kBAAkB;EAClBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,WAAW,GAAGL,uBAAuB,CAAEI,QAAS,CAAC;EAEvD,OACCE,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACV,aAAa;IACbY,KAAK,EAAGV,EAAE,CAAE,qBAAsB,CAAG;IACrCW,IAAI,EAAGX,EAAE,CACR,0DACD,CAAG;IACHY,OAAO,EAAG,CAAC,CAAER,kBAAoB;IACjCS,QAAQ,EAAGN,WAAW,CAACO,MAAQ;IAC/BC,QAAQ,EAAKC,KAAK,IAAM;MACvBX,aAAa,CAAE;QACdD,kBAAkB,EAAE,CAAC,CAAEY;MACxB,CAAE,CAAC;IACJ;EAAG,CACH,CAAC,EACA,CAAC,CAAET,WAAW,CAACO,MAAM,IACtBN,aAAA,CAACT,MAAM;IACNkB,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG,KAAO;IACvBC,SAAS,EAAC;EAA4C,GAEpDnB,EAAE,CACH,2DACD,CAAC,EACDQ,aAAA,aACGD,WAAW,CAACa,GAAG,CAAIC,EAAE,IACtBb,aAAA;IAAIc,GAAG,EAAGD;EAAI,GACbb,aAAA,CAACP,UAAU;IAACK,QAAQ,EAAGe;EAAI,CAAE,CAC1B,CACH,CACC,CAAC,EACHrB,EAAE,CACH,4EACD,CACO,CAER,CAAC;AAEL"}
@@ -332,19 +332,22 @@ export const usePatterns = (clientId, name) => {
332
332
  };
333
333
 
334
334
  /**
335
- * Hook that returns whether the Query Loop with the given `clientId` contains
336
- * any third-party block.
335
+ * Hook that returns a list of unsupported blocks inside the Query Loop with the
336
+ * given `clientId`.
337
337
  *
338
338
  * @param {string} clientId The block's client ID.
339
- * @return {boolean} True if it contains third-party blocks.
339
+ * @return {string[]} List of block titles.
340
340
  */
341
- export const useContainsThirdPartyBlocks = clientId => {
341
+ export const useUnsupportedBlockList = clientId => {
342
342
  return useSelect(select => {
343
343
  const {
344
344
  getClientIdsOfDescendants,
345
345
  getBlockName
346
346
  } = select(blockEditorStore);
347
- return getClientIdsOfDescendants(clientId).some(descendantClientId => !getBlockName(descendantClientId).startsWith('core/'));
347
+ return getClientIdsOfDescendants(clientId).filter(descendantClientId => {
348
+ const blockName = getBlockName(descendantClientId);
349
+ return !blockName.startsWith('core/') || blockName === 'core/post-content' || blockName === 'core/template-part' || blockName === 'core/block';
350
+ });
348
351
  }, [clientId]);
349
352
  };
350
353
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useContainsThirdPartyBlocks","getClientIdsOfDescendants","getBlockName","some","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = 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\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns whether the Query Loop with the given `clientId` contains\n * any third-party block.\n *\n * @param {string} clientId The block's client ID.\n * @return {boolean} True if it contains third-party blocks.\n */\nexport const useContainsThirdPartyBlocks = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).some(\n\t\t\t\t( descendantClientId ) =>\n\t\t\t\t\t! getBlockName( descendantClientId ).startsWith( 'core/' )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":"AAAA;AACA;A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E,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAE+D,yBAAyB;MAAEC;IAAa,CAAC,GAChDhE,MAAM,CAAE5B,gBAAiB,CAAC;IAE3B,OAAO2F,yBAAyB,CAAEtB,QAAS,CAAC,CAACwB,IAAI,CAC9CC,kBAAkB,IACnB,CAAEF,YAAY,CAAEE,kBAAmB,CAAC,CAACC,UAAU,CAAE,OAAQ,CAC3D,CAAC;EACF,CAAC,EACD,CAAE1B,QAAQ,CACX,CAAC;AACF,CAAC"}
1
+ {"version":3,"names":["useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useUnsupportedBlockList","getClientIdsOfDescendants","getBlockName","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = 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\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns a list of unsupported blocks inside the Query Loop with the\n * given `clientId`.\n *\n * @param {string} clientId The block's client ID.\n * @return {string[]} List of block titles.\n */\nexport const useUnsupportedBlockList = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).filter(\n\t\t\t\t( descendantClientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( descendantClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! blockName.startsWith( 'core/' ) ||\n\t\t\t\t\t\tblockName === 'core/post-content' ||\n\t\t\t\t\t\tblockName === 'core/template-part' ||\n\t\t\t\t\t\tblockName === 'core/block'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEJ,KAAK,IAAIK,WAAW,QAAQ,mBAAmB;;AAEpE;;AAEA;AACA;AACA;AACA;AACA;;AAE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,IACjCnB,SAAS,KAAK,mBAAmB,IACjCA,SAAS,KAAK,oBAAoB,IAClCA,SAAS,KAAK,YAAY;IAE5B,CACD,CAAC;EACF,CAAC,EACD,CAAEN,QAAQ,CACX,CAAC;AACF,CAAC"}
@@ -10,7 +10,6 @@ import initBlock from '../utils/init-block';
10
10
  const metadata = {
11
11
  $schema: "https://schemas.wp.org/trunk/block.json",
12
12
  apiVersion: 3,
13
- __experimental: "fse",
14
13
  name: "core/term-description",
15
14
  title: "Term Description",
16
15
  category: "theme",
@@ -1 +1 @@
1
- {"version":3,"names":["termDescription","icon","initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","textdomain","attributes","textAlign","type","supports","align","html","color","link","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","edit","settings","init"],"sources":["@wordpress/block-library/src/term-description/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;AAAA;AAE5C,OAAOQ,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAE5B;AAAK,CAAC,GAAGJ,QAAQ;AACzB,SAASA,QAAQ,EAAEI,IAAI;AAEvB,OAAO,MAAM6B,QAAQ,GAAG;EACvBnC,IAAI;EACJkC;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMnC,SAAS,CAAE;EAAEK,IAAI;EAAEJ,QAAQ;EAAEiC;AAAS,CAAE,CAAC"}
1
+ {"version":3,"names":["termDescription","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","textAlign","type","supports","align","html","color","link","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","edit","settings","init"],"sources":["@wordpress/block-library/src/term-description/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;AAAA;AAE5C,OAAOQ,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAE5B;AAAK,CAAC,GAAGH,QAAQ;AACzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM6B,QAAQ,GAAG;EACvBlC,IAAI;EACJiC;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMlC,SAAS,CAAE;EAAEI,IAAI;EAAEH,QAAQ;EAAEgC;AAAS,CAAE,CAAC"}
@@ -110,11 +110,6 @@
110
110
  margin-bottom: 1em;
111
111
  }
112
112
 
113
- @media (max-width: 768px) {
114
- .wp-block-file__embed {
115
- display: none;
116
- }
117
- }
118
113
  :where(.wp-block-file__button) {
119
114
  border-radius: 2em;
120
115
  padding: 0.5em 1em;
@@ -111,11 +111,6 @@
111
111
  margin-bottom: 1em;
112
112
  }
113
113
 
114
- @media (max-width: 768px) {
115
- .wp-block-file__embed {
116
- display: none;
117
- }
118
- }
119
114
  :where(.wp-block-file__button) {
120
115
  border-radius: 2em;
121
116
  padding: 0.5em 1em;
@@ -1136,11 +1136,6 @@ section.wp-block-cover-image > h2,
1136
1136
  margin-bottom: 1em;
1137
1137
  }
1138
1138
 
1139
- @media (max-width: 768px) {
1140
- .wp-block-file__embed {
1141
- display: none;
1142
- }
1143
- }
1144
1139
  :where(.wp-block-file__button) {
1145
1140
  border-radius: 2em;
1146
1141
  padding: 0.5em 1em;
@@ -1144,11 +1144,6 @@ section.wp-block-cover-image > h2,
1144
1144
  margin-bottom: 1em;
1145
1145
  }
1146
1146
 
1147
- @media (max-width: 768px) {
1148
- .wp-block-file__embed {
1149
- display: none;
1150
- }
1151
- }
1152
1147
  :where(.wp-block-file__button) {
1153
1148
  border-radius: 2em;
1154
1149
  padding: 0.5em 1em;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.19.9",
3
+ "version": "8.19.10",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,36 +31,36 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.42.9",
35
- "@wordpress/api-fetch": "^6.39.9",
36
- "@wordpress/autop": "^3.42.9",
37
- "@wordpress/blob": "^3.42.9",
38
- "@wordpress/block-editor": "^12.10.9",
39
- "@wordpress/blocks": "^12.19.9",
40
- "@wordpress/components": "^25.8.9",
41
- "@wordpress/compose": "^6.19.9",
42
- "@wordpress/core-data": "^6.19.9",
43
- "@wordpress/data": "^9.12.9",
44
- "@wordpress/date": "^4.42.9",
45
- "@wordpress/deprecated": "^3.42.9",
46
- "@wordpress/dom": "^3.42.9",
47
- "@wordpress/element": "^5.19.9",
48
- "@wordpress/escape-html": "^2.42.9",
49
- "@wordpress/hooks": "^3.42.9",
50
- "@wordpress/html-entities": "^3.42.9",
51
- "@wordpress/i18n": "^4.42.9",
52
- "@wordpress/icons": "^9.33.9",
53
- "@wordpress/interactivity": "^2.3.9",
54
- "@wordpress/keycodes": "^3.42.9",
55
- "@wordpress/notices": "^4.10.9",
56
- "@wordpress/primitives": "^3.40.9",
57
- "@wordpress/private-apis": "^0.24.9",
58
- "@wordpress/reusable-blocks": "^4.19.9",
59
- "@wordpress/rich-text": "^6.19.9",
60
- "@wordpress/server-side-render": "^4.19.9",
61
- "@wordpress/url": "^3.43.9",
62
- "@wordpress/viewport": "^5.19.9",
63
- "@wordpress/wordcount": "^3.42.9",
34
+ "@wordpress/a11y": "^3.42.10",
35
+ "@wordpress/api-fetch": "^6.39.10",
36
+ "@wordpress/autop": "^3.42.10",
37
+ "@wordpress/blob": "^3.42.10",
38
+ "@wordpress/block-editor": "^12.10.10",
39
+ "@wordpress/blocks": "^12.19.10",
40
+ "@wordpress/components": "^25.8.10",
41
+ "@wordpress/compose": "^6.19.10",
42
+ "@wordpress/core-data": "^6.19.10",
43
+ "@wordpress/data": "^9.12.10",
44
+ "@wordpress/date": "^4.42.10",
45
+ "@wordpress/deprecated": "^3.42.10",
46
+ "@wordpress/dom": "^3.42.10",
47
+ "@wordpress/element": "^5.19.10",
48
+ "@wordpress/escape-html": "^2.42.10",
49
+ "@wordpress/hooks": "^3.42.10",
50
+ "@wordpress/html-entities": "^3.42.10",
51
+ "@wordpress/i18n": "^4.42.10",
52
+ "@wordpress/icons": "^9.33.10",
53
+ "@wordpress/interactivity": "^2.3.10",
54
+ "@wordpress/keycodes": "^3.42.10",
55
+ "@wordpress/notices": "^4.10.10",
56
+ "@wordpress/primitives": "^3.40.10",
57
+ "@wordpress/private-apis": "^0.24.10",
58
+ "@wordpress/reusable-blocks": "^4.19.10",
59
+ "@wordpress/rich-text": "^6.19.10",
60
+ "@wordpress/server-side-render": "^4.19.10",
61
+ "@wordpress/url": "^3.43.10",
62
+ "@wordpress/viewport": "^5.19.10",
63
+ "@wordpress/wordcount": "^3.42.10",
64
64
  "change-case": "^4.1.2",
65
65
  "classnames": "^2.3.1",
66
66
  "colord": "^2.7.0",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "869f3c0fffbae25b9caff583ff534881bcba5be6"
81
+ "gitHead": "11504931036f9db3612c82298a7eab60147e0706"
82
82
  }
@@ -59,7 +59,8 @@ function render_block_core_file( $attributes, $content, $block ) {
59
59
  $processor->next_tag();
60
60
  $processor->set_attribute( 'data-wp-interactive', '' );
61
61
  $processor->next_tag( 'object' );
62
- $processor->set_attribute( 'data-wp-style--display', 'selectors.core.file.hasPdfPreview' );
62
+ $processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
63
+ $processor->set_attribute( 'hidden', true );
63
64
  return $processor->get_updated_html();
64
65
  }
65
66
 
@@ -29,12 +29,6 @@
29
29
  margin-bottom: 1em;
30
30
  }
31
31
 
32
- @media (max-width: 768px) {
33
- .wp-block-file__embed {
34
- display: none;
35
- }
36
- }
37
-
38
32
  //This needs a low specificity so it won't override the rules from the button element if defined in theme.json.
39
33
  :where(.wp-block-file__button) {
40
34
  border-radius: 2em;
package/src/file/view.js CHANGED
@@ -5,13 +5,13 @@ import { store } from '@wordpress/interactivity';
5
5
  /**
6
6
  * Internal dependencies
7
7
  */
8
- import { browserSupportsPdfs } from './utils';
8
+ import { browserSupportsPdfs as hasPdfPreview } from './utils';
9
9
 
10
10
  store( {
11
11
  selectors: {
12
12
  core: {
13
13
  file: {
14
- hasPdfPreview: browserSupportsPdfs() ? 'inherit' : 'none',
14
+ hasPdfPreview,
15
15
  },
16
16
  },
17
17
  },
@@ -12,10 +12,10 @@ import { useState, useEffect } from '@wordpress/element';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import { useContainsThirdPartyBlocks } from '../utils';
15
+ import { useUnsupportedBlockList } from '../utils';
16
16
 
17
17
  const disableEnhancedPaginationDescription = __(
18
- 'Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable "Enhanced pagination" in the Query Block settings.'
18
+ 'You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable "Enhanced pagination" in the Query Block settings.'
19
19
  );
20
20
 
21
21
  const modalDescriptionId =
@@ -28,11 +28,11 @@ export default function EnhancedPaginationModal( {
28
28
  } ) {
29
29
  const [ isOpen, setOpen ] = useState( false );
30
30
 
31
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );
31
+ const unsupported = useUnsupportedBlockList( clientId );
32
32
 
33
33
  useEffect( () => {
34
- setOpen( containsThirdPartyBlocks && enhancedPagination );
35
- }, [ containsThirdPartyBlocks, enhancedPagination, setOpen ] );
34
+ setOpen( !! unsupported.length && enhancedPagination );
35
+ }, [ unsupported.length, enhancedPagination, setOpen ] );
36
36
 
37
37
  return (
38
38
  isOpen && (
@@ -3,22 +3,19 @@
3
3
  */
4
4
  import { ToggleControl, Notice } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
+ import { BlockTitle } from '@wordpress/block-editor';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
10
- import { useContainsThirdPartyBlocks } from '../../utils';
11
+ import { useUnsupportedBlockList } from '../../utils';
11
12
 
12
13
  export default function EnhancedPaginationControl( {
13
14
  enhancedPagination,
14
15
  setAttributes,
15
16
  clientId,
16
17
  } ) {
17
- const enhancedPaginationNotice = __(
18
- "Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop."
19
- );
20
-
21
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );
18
+ const unsupported = useUnsupportedBlockList( clientId );
22
19
 
23
20
  return (
24
21
  <>
@@ -28,20 +25,32 @@ export default function EnhancedPaginationControl( {
28
25
  'Browsing between pages won’t require a full page reload.'
29
26
  ) }
30
27
  checked={ !! enhancedPagination }
31
- disabled={ containsThirdPartyBlocks }
28
+ disabled={ unsupported.length }
32
29
  onChange={ ( value ) => {
33
30
  setAttributes( {
34
31
  enhancedPagination: !! value,
35
32
  } );
36
33
  } }
37
34
  />
38
- { containsThirdPartyBlocks && (
35
+ { !! unsupported.length && (
39
36
  <Notice
40
37
  status="warning"
41
38
  isDismissible={ false }
42
39
  className="wp-block-query__enhanced-pagination-notice"
43
40
  >
44
- { enhancedPaginationNotice }
41
+ { __(
42
+ "Enhanced pagination doesn't support the following blocks:"
43
+ ) }
44
+ <ul>
45
+ { unsupported.map( ( id ) => (
46
+ <li key={ id }>
47
+ <BlockTitle clientId={ id } />
48
+ </li>
49
+ ) ) }
50
+ </ul>
51
+ { __(
52
+ 'If you want to enable it, you have to remove all unsupported blocks first.'
53
+ ) }
45
54
  </Notice>
46
55
  ) }
47
56
  </>
@@ -346,21 +346,28 @@ export const usePatterns = ( clientId, name ) => {
346
346
  };
347
347
 
348
348
  /**
349
- * Hook that returns whether the Query Loop with the given `clientId` contains
350
- * any third-party block.
349
+ * Hook that returns a list of unsupported blocks inside the Query Loop with the
350
+ * given `clientId`.
351
351
  *
352
352
  * @param {string} clientId The block's client ID.
353
- * @return {boolean} True if it contains third-party blocks.
353
+ * @return {string[]} List of block titles.
354
354
  */
355
- export const useContainsThirdPartyBlocks = ( clientId ) => {
355
+ export const useUnsupportedBlockList = ( clientId ) => {
356
356
  return useSelect(
357
357
  ( select ) => {
358
358
  const { getClientIdsOfDescendants, getBlockName } =
359
359
  select( blockEditorStore );
360
360
 
361
- return getClientIdsOfDescendants( clientId ).some(
362
- ( descendantClientId ) =>
363
- ! getBlockName( descendantClientId ).startsWith( 'core/' )
361
+ return getClientIdsOfDescendants( clientId ).filter(
362
+ ( descendantClientId ) => {
363
+ const blockName = getBlockName( descendantClientId );
364
+ return (
365
+ ! blockName.startsWith( 'core/' ) ||
366
+ blockName === 'core/post-content' ||
367
+ blockName === 'core/template-part' ||
368
+ blockName === 'core/block'
369
+ );
370
+ }
364
371
  );
365
372
  },
366
373
  [ clientId ]
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": "fse",
5
4
  "name": "core/term-description",
6
5
  "title": "Term Description",
7
6
  "category": "theme",