first commit

This commit is contained in:
Roman Pyrih
2026-05-21 15:33:11 +02:00
commit acb036dbd9
8059 changed files with 2885104 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
// packages/block-library/build-module/query/view.mjs
import {
store,
getContext,
getElement,
withSyncEvent
} from "@wordpress/interactivity";
var isValidLink = (ref) => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === "_self") && ref.origin === window.location.origin;
var isValidEvent = (event) => event.button === 0 && // Left clicks only.
!event.metaKey && // Open in new tab (Mac).
!event.ctrlKey && // Open in new tab (Windows).
!event.altKey && // Download.
!event.shiftKey && !event.defaultPrevented;
store(
"core/query",
{
actions: {
navigate: withSyncEvent(function* (event) {
const ctx = getContext();
const { ref } = getElement();
const queryRef = ref.closest(
".wp-block-query[data-wp-router-region]"
);
if (isValidLink(ref) && isValidEvent(event)) {
event.preventDefault();
const { actions } = yield import("@wordpress/interactivity-router");
yield actions.navigate(ref.href);
ctx.url = ref.href;
const firstAnchor = `.wp-block-post-template a[href]`;
queryRef.querySelector(firstAnchor)?.focus();
}
}),
*prefetch() {
const { ref } = getElement();
if (isValidLink(ref)) {
const { actions } = yield import("@wordpress/interactivity-router");
yield actions.prefetch(ref.href);
}
}
},
callbacks: {
*prefetch() {
const { url } = getContext();
const { ref } = getElement();
if (url && isValidLink(ref)) {
const { actions } = yield import("@wordpress/interactivity-router");
yield actions.prefetch(ref.href);
}
}
}
},
{ lock: true }
);

View File

@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'module_dependencies' => array(array('id' => '@wordpress/interactivity', 'import' => 'static'), array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => '7a4ec5bfb61a7137cf4b');

View File

@@ -0,0 +1 @@
import{store as a,getContext as c,getElement as r,withSyncEvent as l}from"@wordpress/interactivity";var i=t=>t&&t instanceof window.HTMLAnchorElement&&t.href&&(!t.target||t.target==="_self")&&t.origin===window.location.origin,f=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&!t.defaultPrevented;a("core/query",{actions:{navigate:l(function*(t){let e=c(),{ref:o}=r(),n=o.closest(".wp-block-query[data-wp-router-region]");if(i(o)&&f(t)){t.preventDefault();let{actions:s}=yield import("@wordpress/interactivity-router");yield s.navigate(o.href),e.url=o.href,n.querySelector(".wp-block-post-template a[href]")?.focus()}}),*prefetch(){let{ref:t}=r();if(i(t)){let{actions:e}=yield import("@wordpress/interactivity-router");yield e.prefetch(t.href)}}},callbacks:{*prefetch(){let{url:t}=c(),{ref:e}=r();if(t&&i(e)){let{actions:o}=yield import("@wordpress/interactivity-router");yield o.prefetch(e.href)}}}},{lock:!0});