PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / QuickEdit / lib / agent-gate.js

agent-gate.js in Extendify 3.1.0, at src/QuickEdit/lib/agent-gate.js

21 lines 768 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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