@wordpress/block-library 8.19.0 → 8.19.1

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.
@@ -30,6 +30,8 @@ const PatternEdit = ({
30
30
  getBlockRootClientId,
31
31
  getBlockEditingMode
32
32
  } = (0, _data.useSelect)(_blockEditor.store);
33
+
34
+ // Duplicated in packages/edit-site/src/components/start-template-options/index.js.
33
35
  function injectThemeAttributeInBlockTemplateContent(block) {
34
36
  if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
35
37
  block.innerBlocks = block.innerBlocks.map(innerBlock => {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_blocks","_data","_blockEditor","_coreData","PatternEdit","attributes","clientId","selectedPattern","useSelect","select","blockEditorStore","__experimentalGetParsedPattern","slug","currentThemeStylesheet","coreStore","getCurrentTheme","stylesheet","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","useDispatch","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","useEffect","blocks","window","queueMicrotask","rootClientId","clonedBlocks","cloneBlock","rootEditingMode","props","useBlockProps","createElement","_default","exports","default"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAFA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,SAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAUA,MAAMK,WAAW,GAAGA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,KAAM;EACnD,MAAMC,eAAe,GAAG,IAAAC,eAAS,EAC9BC,MAAM,IACPA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,8BAA8B,CACxDN,UAAU,CAACO,IACZ,CAAC,EACF,CAAEP,UAAU,CAACO,IAAI,CAClB,CAAC;EAED,MAAMC,sBAAsB,GAAG,IAAAL,eAAS,EACrCC,MAAM,IAAMA,MAAM,CAAEK,e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vD,IAAAc,kBAAU,EACTf,0CAA0C,CAAEC,KAAM,CACnD,CACD,CAAC;QACD,MAAMe,eAAe,GAAGjB,mBAAmB,CAAEc,YAAa,CAAC;QAC3D;QACA;QACAlB,uCAAuC,CAAC,CAAC;QACzCE,mBAAmB,CAAEgB,YAAY,EAAE,SAAU,CAAC;QAC9ClB,uCAAuC,CAAC,CAAC;QACzCD,aAAa,CAAEX,QAAQ,EAAE+B,YAAa,CAAC;QACvC;QACAnB,uCAAuC,CAAC,CAAC;QACzCE,mBAAmB,CAAEgB,YAAY,EAAEG,eAAgB,CAAC;MACrD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACFjC,QAAQ,EACRC,eAAe,EAAE0B,MAAM,EACvBf,uCAAuC,EACvCD,aAAa,EACbK,mBAAmB,EACnBF,mBAAmB,EACnBC,oBAAoB,CACnB,CAAC;EAEH,MAAMmB,KAAK,GAAG,IAAAC,0BAAa,EAAC,CAAC;EAE7B,OAAO,IAAA3C,QAAA,CAAA4C,aAAA;IAAA,GAAUF;EAAK,CAAI,CAAC;AAC5B,CAAC;AAAC,IAAAG,QAAA,GAEavC,WAAW;AAAAwC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_element","require","_blocks","_data","_blockEditor","_coreData","PatternEdit","attributes","clientId","selectedPattern","useSelect","select","blockEditorStore","__experimentalGetParsedPattern","slug","currentThemeStylesheet","coreStore","getCurrentTheme","stylesheet","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","useDispatch","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","useEffect","blocks","window","queueMicrotask","rootClientId","clonedBlocks","cloneBlock","rootEditingMode","props","useBlockProps","createElement","_default","exports","default"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAFA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,YA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S,EACnC;MACDP,KAAK,CAACnB,UAAU,CAACyB,KAAK,GAAGjB,sBAAsB;IAChD;IACA,OAAOW,KAAK;EACb;;EAEA;EACA;EACA;EACA;EACA,IAAAQ,kBAAS,EAAE,MAAM;IAChB,IAAKzB,eAAe,EAAE0B,MAAM,EAAG;MAC9B;MACA;MACA;MACA;MACA;MACAC,MAAM,CAACC,cAAc,CAAE,MAAM;QAC5B,MAAMC,YAAY,GAAGf,oBAAoB,CAAEf,QAAS,CAAC;QACrD;QACA;QACA,MAAM+B,YAAY,GAAG9B,eAAe,CAAC0B,MAAM,CAACJ,GAAG,CAAIL,KAAK,IACvD,IAAAc,kBAAU,EACTf,0CAA0C,CAAEC,KAAM,CACnD,CACD,CAAC;QACD,MAAMe,eAAe,GAAGjB,mBAAmB,CAAEc,YAAa,CAAC;QAC3D;QACA;QACAlB,uCAAuC,CAAC,CAAC;QACzCE,mBAAmB,CAAEgB,YAAY,EAAE,SAAU,CAAC;QAC9ClB,uCAAuC,CAAC,CAAC;QACzCD,aAAa,CAAEX,QAAQ,EAAE+B,YAAa,CAAC;QACvC;QACAnB,uCAAuC,CAAC,CAAC;QACzCE,mBAAmB,CAAEgB,YAAY,EAAEG,eAAgB,CAAC;MACrD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACFjC,QAAQ,EACRC,eAAe,EAAE0B,MAAM,EACvBf,uCAAuC,EACvCD,aAAa,EACbK,mBAAmB,EACnBF,mBAAmB,EACnBC,oBAAoB,CACnB,CAAC;EAEH,MAAMmB,KAAK,GAAG,IAAAC,0BAAa,EAAC,CAAC;EAE7B,OAAO,IAAA3C,QAAA,CAAA4C,aAAA;IAAA,GAAUF;EAAK,CAAI,CAAC;AAC5B,CAAC;AAAC,IAAAG,QAAA,GAEavC,WAAW;AAAAwC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -55,9 +55,11 @@ const isValidEvent = event => event.button === 0 &&
55
55
  // package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
56
56
  context.core.query.message = context.core.query.loadedText + (context.core.query.message === context.core.query.loadedText ? '\u00A0' : '');
57
57
  context.core.query.animation = 'finish';
58
+ context.core.query.url = ref.href;
58
59
 
59
60
  // Focus the first anchor of the Query block.
60
- document.querySelector(`[data-wp-navigation-id=${id}] a[href]`)?.focus();
61
+ const firstAnchor = `[data-wp-navigation-id=${id}] .wp-block-post-template a[href]`;
62
+ document.querySelector(firstAnchor)?.focus();
61
63
  }
62
64
  },
63
65
  prefetch: async ({
@@ -69,6 +71,20 @@ const isValidEvent = event => event.button === 0 &&
69
71
  }
70
72
  }
71
73
  }
74
+ },
75
+ effects: {
76
+ core: {
77
+ query: {
78
+ prefetch: async ({
79
+ ref,
80
+ context
81
+ }) => {
82
+ if (context.core.query.url && isValidLink(ref)) {
83
+ await (0, _interactivity.prefetch)(ref.href);
84
+ }
85
+ }
86
+ }
87
+ }
72
88
  }
73
89
  });
74
90
  //# sourceMappingURL=view.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_interactivity","require","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","store","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","navigate","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","document","querySelector","focus","prefetch"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tcontext.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 400 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tcontext.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tcontext.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tdocument\n\t\t\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t\t\t`[data-wp-navigation-id=${ id }] a[href]`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAAG,CAACK,MAAM,KAAKJ,MAAM,CAACK,QAAQ,CAACD,MAAM;AAEtC,MAAME,YAAY,GAAKC,KAAK,IAC3BA,KAAK,CAACC,MAAM,KAAK,CAAC;AAAI;AACtB,CAAED,KAAK,CAACE,OAAO;AAAI;AACnB,CAAEF,KAAK,CAACG,OAAO;AAAI;AACnB,CAAEH,KAAK,CAACI,MAAM;AAAI;AAClB,CAAEJ,KAAK,CAACK,QAAQ,IAChB,CAAEL,KAAK,CAACM,gBAAgB;AAEzB,IAAAC,oBAAK,EAAE;EACNC,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,KAAK,EAAE;QACNC,cAAc,EAAEA,CAAE;UAAEC;QAAQ,CAAC,KAC5BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK,OAAO;QACzCC,eAAe,EAAEA,CAAE;UAAEF;QAAQ,CAAC,KAC7BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK;MACnC;IACD;EACD,CAAC;EACDE,OAAO,EAAE;IACRN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,EAAEvC,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["_interactivity","require","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","store","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","navigate","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","url","firstAnchor","document","querySelector","focus","prefetch","effects"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tcontext.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 400 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tcontext.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tcontext.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\t\t\t\t\t\tcontext.core.query.url = ref.href;\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tconst firstAnchor = `[data-wp-navigation-id=${ id }] .wp-block-post-template a[href]`;\n\t\t\t\t\t\tdocument.querySelector( firstAnchor )?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\teffects: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tprefetch: async ( { ref, context } ) => {\n\t\t\t\t\tif ( context.core.query.url && isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAA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,CAACkB,GAAG,IAAIrC,WAAW,CAAEC,GAAI,CAAC,EAAG;YACnD,MAAM,IAAAyC,uBAAQ,EAAEzC,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -24,6 +24,8 @@ const PatternEdit = ({
24
24
  getBlockRootClientId,
25
25
  getBlockEditingMode
26
26
  } = useSelect(blockEditorStore);
27
+
28
+ // Duplicated in packages/edit-site/src/components/start-template-options/index.js.
27
29
  function injectThemeAttributeInBlockTemplateContent(block) {
28
30
  if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
29
31
  block.innerBlocks = block.innerBlocks.map(innerBlock => {
@@ -1 +1 @@
1
- {"version":3,"names":["cloneBlock","useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockProps","coreStore","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","currentThemeStylesheet","getCurrentTheme","stylesheet","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","blocks","window","queueMicrotask","rootClientId","clonedBlocks","rootEditingMode","props","createElement"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;AAEzD,MAAMC,WAAW,GAAGA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,KAAM;EACnD,MAAMC,eAAe,GAAGV,SAAS,CAC9BW,MAAM,IACPA,MAAM,CAAEP,gBAAiB,CAAC,CAACQ,8BAA8B,CACxDJ,UAAU,CAACK,IACZ,CAAC,EACF,CAAEL,UAAU,CAACK,IAAI,CAClB,CAAC;EAED,MAAMC,sBAAsB,G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AG,CAAIL,KAAK,IACvDxB,UAAU,CACTuB,0CAA0C,CAAEC,KAAM,CACnD,CACD,CAAC;QACD,MAAMa,eAAe,GAAGf,mBAAmB,CAAEa,YAAa,CAAC;QAC3D;QACA;QACAhB,uCAAuC,CAAC,CAAC;QACzCC,mBAAmB,CAAEe,YAAY,EAAE,SAAU,CAAC;QAC9ChB,uCAAuC,CAAC,CAAC;QACzCD,aAAa,CAAER,QAAQ,EAAE0B,YAAa,CAAC;QACvC;QACAjB,uCAAuC,CAAC,CAAC;QACzCC,mBAAmB,CAAEe,YAAY,EAAEE,eAAgB,CAAC;MACrD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACF3B,QAAQ,EACRC,eAAe,EAAEqB,MAAM,EACvBb,uCAAuC,EACvCD,aAAa,EACbI,mBAAmB,EACnBF,mBAAmB,EACnBC,oBAAoB,CACnB,CAAC;EAEH,MAAMiB,KAAK,GAAGhC,aAAa,CAAC,CAAC;EAE7B,OAAOiC,aAAA;IAAA,GAAUD;EAAK,CAAI,CAAC;AAC5B,CAAC;AAED,eAAe9B,WAAW"}
1
+ {"version":3,"names":["cloneBlock","useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockProps","coreStore","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","currentThemeStylesheet","getCurrentTheme","stylesheet","replaceBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","getBlockRootClientId","getBlockEditingMode","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","blocks","window","queueMicrotask","rootClientId","clonedBlocks","rootEditingMode","props","createElement"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\tconst { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { setBlockEditingMode } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASF,KAAK,IAAIG,SAAS,QAA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,KAAK;EACb;;EAEA;EACA;EACA;EACA;EACArB,SAAS,CAAE,MAAM;IAChB,IAAKQ,eAAe,EAAEqB,MAAM,EAAG;MAC9B;MACA;MACA;MACA;MACA;MACAC,MAAM,CAACC,cAAc,CAAE,MAAM;QAC5B,MAAMC,YAAY,GAAGd,oBAAoB,CAAEX,QAAS,CAAC;QACrD;QACA;QACA,MAAM0B,YAAY,GAAGzB,eAAe,CAACqB,MAAM,CAACH,GAAG,CAAIL,KAAK,IACvDxB,UAAU,CACTuB,0CAA0C,CAAEC,KAAM,CACnD,CACD,CAAC;QACD,MAAMa,eAAe,GAAGf,mBAAmB,CAAEa,YAAa,CAAC;QAC3D;QACA;QACAhB,uCAAuC,CAAC,CAAC;QACzCC,mBAAmB,CAAEe,YAAY,EAAE,SAAU,CAAC;QAC9ChB,uCAAuC,CAAC,CAAC;QACzCD,aAAa,CAAER,QAAQ,EAAE0B,YAAa,CAAC;QACvC;QACAjB,uCAAuC,CAAC,CAAC;QACzCC,mBAAmB,CAAEe,YAAY,EAAEE,eAAgB,CAAC;MACrD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACF3B,QAAQ,EACRC,eAAe,EAAEqB,MAAM,EACvBb,uCAAuC,EACvCD,aAAa,EACbI,mBAAmB,EACnBF,mBAAmB,EACnBC,oBAAoB,CACnB,CAAC;EAEH,MAAMiB,KAAK,GAAGhC,aAAa,CAAC,CAAC;EAE7B,OAAOiC,aAAA;IAAA,GAAUD;EAAK,CAAI,CAAC;AAC5B,CAAC;AAED,eAAe9B,WAAW"}
@@ -52,9 +52,11 @@ store({
52
52
  // package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
53
53
  context.core.query.message = context.core.query.loadedText + (context.core.query.message === context.core.query.loadedText ? '\u00A0' : '');
54
54
  context.core.query.animation = 'finish';
55
+ context.core.query.url = ref.href;
55
56
 
56
57
  // Focus the first anchor of the Query block.
57
- document.querySelector(`[data-wp-navigation-id=${id}] a[href]`)?.focus();
58
+ const firstAnchor = `[data-wp-navigation-id=${id}] .wp-block-post-template a[href]`;
59
+ document.querySelector(firstAnchor)?.focus();
58
60
  }
59
61
  },
60
62
  prefetch: async ({
@@ -66,6 +68,20 @@ store({
66
68
  }
67
69
  }
68
70
  }
71
+ },
72
+ effects: {
73
+ core: {
74
+ query: {
75
+ prefetch: async ({
76
+ ref,
77
+ context
78
+ }) => {
79
+ if (context.core.query.url && isValidLink(ref)) {
80
+ await prefetch(ref.href);
81
+ }
82
+ }
83
+ }
84
+ }
69
85
  }
70
86
  });
71
87
  //# sourceMappingURL=view.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["store","navigate","prefetch","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","document","querySelector","focus"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tcontext.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 400 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tcontext.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tcontext.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tdocument\n\t\t\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t\t\t`[data-wp-navigation-id=${ id }] a[href]`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\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c,CAAC,CAAC;YAEtB,MAAMC,EAAE,GAAGxB,GAAG,CAACyB,OAAO,CAAE,yBAA0B,CAAC,CACjDC,OAAO,CAACC,cAAc;;YAExB;YACA,MAAMC,OAAO,GAAGC,UAAU,CAAE,MAAM;cACjCV,OAAO,CAACH,IAAI,CAACC,KAAK,CAACa,OAAO,GACzBX,OAAO,CAACH,IAAI,CAACC,KAAK,CAACc,WAAW;cAC/BZ,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,GAAG,OAAO;YACvC,CAAC,EAAE,GAAI,CAAC;YAER,MAAMvB,QAAQ,CAAEG,GAAG,CAACG,IAAK,CAAC;;YAE1B;YACA6B,YAAY,CAAEJ,OAAQ,CAAC;;YAEvB;YACA;YACA;YACAT,OAAO,CAACH,IAAI,CAACC,KAAK,CAACa,OAAO,GACzBX,OAAO,CAACH,IAAI,CAACC,KAAK,CAACgB,UAAU,IAC3Bd,OAAO,CAACH,IAAI,CAACC,KAAK,CAACa,OAAO,KAC5BX,OAAO,CAACH,IAAI,CAACC,KAAK,CAACgB,UAAU,GAC1B,QAAQ,GACR,EAAE,CAAE;YAERd,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,GAAG,QAAQ;;YAEvC;YACAc,QAAQ,CACNC,aAAa,CACZ,0BAA0BX,EAAI,WAChC,CAAC,EACCY,KAAK,CAAC,CAAC;UACX;QACD,CAAC;QACDtC,QAAQ,EAAE,MAAAA,CAAQ;UAAEE;QAAI,CAAC,KAAM;UAC9B,IAAKD,WAAW,CAAEC,GAAI,CAAC,EAAG;YACzB,MAAMF,QAAQ,CAAEE,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["store","navigate","prefetch","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","url","firstAnchor","document","querySelector","focus","effects"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tcontext.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 400 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tcontext.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tcontext.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\t\t\t\t\t\tcontext.core.query.url = ref.href;\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tconst firstAnchor = `[data-wp-navigation-id=${ id }] .wp-block-post-template a[href]`;\n\t\t\t\t\t\tdocument.querySelector( firstAnchor )?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\teffects: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tprefetch: async ( { ref, context } ) => {\n\t\t\t\t\tif ( context.core.query.url && isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,0BAA0B;AAEpE,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAA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Q,CAAEG,GAAG,CAACG,IAAK,CAAC;;YAE1B;YACA6B,YAAY,CAAEJ,OAAQ,CAAC;;YAEvB;YACA;YACA;YACAT,OAAO,CAACH,IAAI,CAACC,KAAK,CAACa,OAAO,GACzBX,OAAO,CAACH,IAAI,CAACC,KAAK,CAACgB,UAAU,IAC3Bd,OAAO,CAACH,IAAI,CAACC,KAAK,CAACa,OAAO,KAC5BX,OAAO,CAACH,IAAI,CAACC,KAAK,CAACgB,UAAU,GAC1B,QAAQ,GACR,EAAE,CAAE;YAERd,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,GAAG,QAAQ;YACvCD,OAAO,CAACH,IAAI,CAACC,KAAK,CAACiB,GAAG,GAAGlC,GAAG,CAACG,IAAI;;YAEjC;YACA,MAAMgC,WAAW,GAAI,0BAA0BX,EAAI,mCAAkC;YACrFY,QAAQ,CAACC,aAAa,CAAEF,WAAY,CAAC,EAAEG,KAAK,CAAC,CAAC;UAC/C;QACD,CAAC;QACDxC,QAAQ,EAAE,MAAAA,CAAQ;UAAEE;QAAI,CAAC,KAAM;UAC9B,IAAKD,WAAW,CAAEC,GAAI,CAAC,EAAG;YACzB,MAAMF,QAAQ,CAAEE,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD,CAAC;EACDoC,OAAO,EAAE;IACRvB,IAAI,EAAE;MACLC,KAAK,EAAE;QACNnB,QAAQ,EAAE,MAAAA,CAAQ;UAAEE,GAAG;UAAEmB;QAAQ,CAAC,KAAM;UACvC,IAAKA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACiB,GAAG,IAAInC,WAAW,CAAEC,GAAI,CAAC,EAAG;YACnD,MAAMF,QAAQ,CAAEE,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.19.0",
3
+ "version": "8.19.1",
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.0",
35
- "@wordpress/api-fetch": "^6.39.0",
36
- "@wordpress/autop": "^3.42.0",
37
- "@wordpress/blob": "^3.42.0",
38
- "@wordpress/block-editor": "^12.10.0",
39
- "@wordpress/blocks": "^12.19.0",
40
- "@wordpress/components": "^25.8.0",
41
- "@wordpress/compose": "^6.19.0",
42
- "@wordpress/core-data": "^6.19.0",
43
- "@wordpress/data": "^9.12.0",
44
- "@wordpress/date": "^4.42.0",
45
- "@wordpress/deprecated": "^3.42.0",
46
- "@wordpress/dom": "^3.42.0",
47
- "@wordpress/element": "^5.19.0",
48
- "@wordpress/escape-html": "^2.42.0",
49
- "@wordpress/hooks": "^3.42.0",
50
- "@wordpress/html-entities": "^3.42.0",
51
- "@wordpress/i18n": "^4.42.0",
52
- "@wordpress/icons": "^9.33.0",
53
- "@wordpress/interactivity": "^2.3.0",
54
- "@wordpress/keycodes": "^3.42.0",
55
- "@wordpress/notices": "^4.10.0",
56
- "@wordpress/primitives": "^3.40.0",
57
- "@wordpress/private-apis": "^0.24.0",
58
- "@wordpress/reusable-blocks": "^4.19.0",
59
- "@wordpress/rich-text": "^6.19.0",
60
- "@wordpress/server-side-render": "^4.19.0",
61
- "@wordpress/url": "^3.43.0",
62
- "@wordpress/viewport": "^5.19.0",
63
- "@wordpress/wordcount": "^3.42.0",
34
+ "@wordpress/a11y": "^3.42.1",
35
+ "@wordpress/api-fetch": "^6.39.1",
36
+ "@wordpress/autop": "^3.42.1",
37
+ "@wordpress/blob": "^3.42.1",
38
+ "@wordpress/block-editor": "^12.10.1",
39
+ "@wordpress/blocks": "^12.19.1",
40
+ "@wordpress/components": "^25.8.1",
41
+ "@wordpress/compose": "^6.19.1",
42
+ "@wordpress/core-data": "^6.19.1",
43
+ "@wordpress/data": "^9.12.1",
44
+ "@wordpress/date": "^4.42.1",
45
+ "@wordpress/deprecated": "^3.42.1",
46
+ "@wordpress/dom": "^3.42.1",
47
+ "@wordpress/element": "^5.19.1",
48
+ "@wordpress/escape-html": "^2.42.1",
49
+ "@wordpress/hooks": "^3.42.1",
50
+ "@wordpress/html-entities": "^3.42.1",
51
+ "@wordpress/i18n": "^4.42.1",
52
+ "@wordpress/icons": "^9.33.1",
53
+ "@wordpress/interactivity": "^2.3.1",
54
+ "@wordpress/keycodes": "^3.42.1",
55
+ "@wordpress/notices": "^4.10.1",
56
+ "@wordpress/primitives": "^3.40.1",
57
+ "@wordpress/private-apis": "^0.24.1",
58
+ "@wordpress/reusable-blocks": "^4.19.1",
59
+ "@wordpress/rich-text": "^6.19.1",
60
+ "@wordpress/server-side-render": "^4.19.1",
61
+ "@wordpress/url": "^3.43.1",
62
+ "@wordpress/viewport": "^5.19.1",
63
+ "@wordpress/wordcount": "^3.42.1",
64
64
  "change-case": "^4.1.2",
65
65
  "classnames": "^2.3.1",
66
66
  "colord": "^2.7.0",
@@ -69,7 +69,7 @@
69
69
  "fast-deep-equal": "^3.1.3",
70
70
  "memize": "^2.1.0",
71
71
  "remove-accents": "^0.5.0",
72
- "uuid": "^8.3.0"
72
+ "uuid": "^9.0.1"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "react": "^18.0.0",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "cc35f517ed017ab7131319af3e87c359e8de175d"
81
+ "gitHead": "4987d16acb5c41b62704dc4f88225acb97ddd698"
82
82
  }
@@ -64,9 +64,9 @@ describe( 'Cover block', () => {
64
64
  await setup();
65
65
 
66
66
  expect(
67
- screen.getByRole( 'group', {
68
- name: 'To edit this block, you need permission to upload media.',
69
- } )
67
+ within( screen.getByLabelText( 'Block: Cover' ) ).getByText(
68
+ 'To edit this block, you need permission to upload media.'
69
+ )
70
70
  ).toBeInTheDocument();
71
71
  } );
72
72
 
@@ -70,6 +70,8 @@ function render_block_core_file( $attributes, $content, $block ) {
70
70
  * Ensure that the view script has the `wp-interactivity` dependency.
71
71
  *
72
72
  * @since 6.4.0
73
+ *
74
+ * @global WP_Scripts $wp_scripts
73
75
  */
74
76
  function block_core_file_ensure_interactivity_dependency() {
75
77
  global $wp_scripts;
@@ -91,16 +91,16 @@ function block_core_image_get_lightbox_settings( $block ) {
91
91
  }
92
92
 
93
93
  if ( ! isset( $lightbox_settings ) ) {
94
- $lightbox_settings = gutenberg_get_global_settings( array( 'lightbox' ), array( 'block_name' => 'core/image' ) );
94
+ $lightbox_settings = wp_get_global_settings( array( 'lightbox' ), array( 'block_name' => 'core/image' ) );
95
95
 
96
96
  // If not present in global settings, check the top-level global settings.
97
97
  //
98
98
  // NOTE: If no block-level settings are found, the previous call to
99
- // `gutenberg_get_global_settings` will return the whole `theme.json`
99
+ // `wp_get_global_settings` will return the whole `theme.json`
100
100
  // structure in which case we can check if the "lightbox" key is present at
101
101
  // the top-level of the global settings and use its value.
102
102
  if ( isset( $lightbox_settings['lightbox'] ) ) {
103
- $lightbox_settings = gutenberg_get_global_settings( array( 'lightbox' ) );
103
+ $lightbox_settings = wp_get_global_settings( array( 'lightbox' ) );
104
104
  }
105
105
  }
106
106
 
@@ -117,7 +117,7 @@ function block_core_image_get_lightbox_settings( $block ) {
117
117
  function block_core_image_render_lightbox( $block_content, $block ) {
118
118
  $processor = new WP_HTML_Tag_Processor( $block_content );
119
119
 
120
- $aria_label = __( 'Enlarge image', 'gutenberg' );
120
+ $aria_label = __( 'Enlarge image' );
121
121
 
122
122
  $alt_attribute = $processor->get_attribute( 'alt' );
123
123
 
@@ -127,7 +127,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
127
127
 
128
128
  if ( $alt_attribute ) {
129
129
  /* translators: %s: Image alt text. */
130
- $aria_label = sprintf( __( 'Enlarge image: %s', 'gutenberg' ), $alt_attribute );
130
+ $aria_label = sprintf( __( 'Enlarge image: %s' ), $alt_attribute );
131
131
  }
132
132
  $content = $processor->get_updated_html();
133
133
 
@@ -251,8 +251,8 @@ function block_core_image_render_lightbox( $block_content, $block ) {
251
251
 
252
252
  $close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
253
253
  $close_button_color = esc_attr( wp_get_global_styles( array( 'color', 'text' ) ) );
254
- $dialog_label = $alt_attribute ? esc_attr( $alt_attribute ) : esc_attr__( 'Image', 'gutenberg' );
255
- $close_button_label = esc_attr__( 'Close', 'gutenberg' );
254
+ $dialog_label = $alt_attribute ? esc_attr( $alt_attribute ) : esc_attr__( 'Image' );
255
+ $close_button_label = esc_attr__( 'Close' );
256
256
 
257
257
  $lightbox_html = <<<HTML
258
258
  <div data-wp-body="" class="wp-lightbox-overlay $lightbox_animation"
@@ -286,6 +286,8 @@ HTML;
286
286
  * Ensure that the view script has the `wp-interactivity` dependency.
287
287
  *
288
288
  * @since 6.4.0
289
+ *
290
+ * @global WP_Scripts $wp_scripts
289
291
  */
290
292
  function block_core_image_ensure_interactivity_dependency() {
291
293
  global $wp_scripts;
@@ -813,6 +813,8 @@ add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_back
813
813
  * Ensure that the view script has the `wp-interactivity` dependency.
814
814
  *
815
815
  * @since 6.4.0
816
+ *
817
+ * @global WP_Scripts $wp_scripts
816
818
  */
817
819
  function block_core_navigation_ensure_interactivity_dependency() {
818
820
  global $wp_scripts;
@@ -29,6 +29,7 @@ const PatternEdit = ( { attributes, clientId } ) => {
29
29
  const { getBlockRootClientId, getBlockEditingMode } =
30
30
  useSelect( blockEditorStore );
31
31
 
32
+ // Duplicated in packages/edit-site/src/components/start-template-options/index.js.
32
33
  function injectThemeAttributeInBlockTemplateContent( block ) {
33
34
  if (
34
35
  block.innerBlocks.find(
@@ -41,12 +41,12 @@ function render_block_core_pattern( $attributes ) {
41
41
  }
42
42
 
43
43
  $pattern = $registry->get_registered( $slug );
44
- $content = _inject_theme_attribute_in_block_template_content( $pattern['content'] );
44
+ $content = $pattern['content'];
45
45
 
46
+ // Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin.
46
47
  // This can be removed when the minimum supported WordPress is >= 6.4.
47
- if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
48
- // TODO: In the long run, we'd likely want to have a filter in the `WP_Block_Patterns_Registry` class
49
- // instead to allow us plugging in code like this.
48
+ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) {
49
+ $content = _inject_theme_attribute_in_block_template_content( $content );
50
50
  $blocks = parse_blocks( $content );
51
51
  $content = gutenberg_serialize_blocks( $blocks );
52
52
  }
@@ -95,6 +95,8 @@ function render_block_core_query( $attributes, $content, $block ) {
95
95
  * Ensure that the view script has the `wp-interactivity` dependency.
96
96
  *
97
97
  * @since 6.4.0
98
+ *
99
+ * @global WP_Scripts $wp_scripts
98
100
  */
99
101
  function block_core_query_ensure_interactivity_dependency() {
100
102
  global $wp_scripts;
package/src/query/view.js CHANGED
@@ -62,13 +62,11 @@ store( {
62
62
  : '' );
63
63
 
64
64
  context.core.query.animation = 'finish';
65
+ context.core.query.url = ref.href;
65
66
 
66
67
  // Focus the first anchor of the Query block.
67
- document
68
- .querySelector(
69
- `[data-wp-navigation-id=${ id }] a[href]`
70
- )
71
- ?.focus();
68
+ const firstAnchor = `[data-wp-navigation-id=${ id }] .wp-block-post-template a[href]`;
69
+ document.querySelector( firstAnchor )?.focus();
72
70
  }
73
71
  },
74
72
  prefetch: async ( { ref } ) => {
@@ -79,4 +77,15 @@ store( {
79
77
  },
80
78
  },
81
79
  },
80
+ effects: {
81
+ core: {
82
+ query: {
83
+ prefetch: async ( { ref, context } ) => {
84
+ if ( context.core.query.url && isValidLink( ref ) ) {
85
+ await prefetch( ref.href );
86
+ }
87
+ },
88
+ },
89
+ },
90
+ },
82
91
  } );
@@ -74,6 +74,7 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
74
74
  $p->set_attribute( 'data-wp-key', 'query-pagination-next' );
75
75
  $p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
76
76
  $p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' );
77
+ $p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' );
77
78
  $content = $p->get_updated_html();
78
79
  }
79
80
  }
@@ -62,6 +62,7 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
62
62
  $p->set_attribute( 'data-wp-key', 'query-pagination-previous' );
63
63
  $p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
64
64
  $p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' );
65
+ $p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' );
65
66
  $content = $p->get_updated_html();
66
67
  }
67
68
  }
@@ -210,6 +210,8 @@ add_action( 'init', 'register_block_core_search' );
210
210
  * Ensure that the view script has the `wp-interactivity` dependency.
211
211
  *
212
212
  * @since 6.4.0
213
+ *
214
+ * @global WP_Scripts $wp_scripts
213
215
  */
214
216
  function block_core_search_ensure_interactivity_dependency() {
215
217
  global $wp_scripts;