| 1 |
// Mirrors DOMHighlighter's eligibility gates so the Ask AI pill only |
| 2 |
// surfaces on blocks the agent's selector tool would have accepted — |
| 3 |
// keeps the two selectors in lockstep until DOMHighlighter shrinks to |
| 4 |
// a passive renderer. |
| 5 |
const IGNORED_CLASS_RX = /^(wp-block-video|wp-block-spacer|wp-block-post-.*)$/; |
| 6 |
const TAGGED_INNER_SEL = |
| 7 |
'[data-extendify-agent-block-id], [data-extendify-part-block-id], .wp-block-navigation'; |
| 8 |
const MAX_INNER_TAGGED = 50; |
| 9 |
|
| 10 |
export const isAgentEligibleForTarget = (target) => { |
| 11 |
const el = target?.el; |
| 12 |
if (!el?.classList) return false; |
| 13 |
for (const cls of el.classList) { |
| 14 |
if (IGNORED_CLASS_RX.test(cls)) return false; |
| 15 |
} |
| 16 |
if (el.querySelectorAll(TAGGED_INNER_SEL).length > MAX_INNER_TAGGED) { |
| 17 |
return false; |
| 18 |
} |
| 19 |
return true; |
| 20 |
}; |
| 21 |
|