import { findBlockEl, scopeOf } from '@agent/lib/block-el'; import { buildSubtreeManifest } from '@agent/lib/subtree-manifest'; import { useQuickEditStore } from '@quick-edit/state/store'; import { useMemo } from '@wordpress/element'; import { __, _n, sprintf } from '@wordpress/i18n'; import { close, Icon } from '@wordpress/icons'; import classNames from 'classnames'; export const PageDocument = ({ busy }) => { const setBlock = useQuickEditStore((s) => s.setAgentBlock); const block = useQuickEditStore((s) => s.agentBlock); // The same manifest the agent works from, so the count matches what it // can actually address — not every node in the subtree. const count = useMemo(() => { if (!block?.id) return 1; const node = findBlockEl(block.id, document, scopeOf(block)); return Math.max(node ? buildSubtreeManifest(node).length : 1, 1); }, [block]); return ( // The input darkens to gray-300 while disabled; a gray-200 chip vanishes into it.