site-builder: dynamic CTAs, section anchors, edit-with-Sitesmith
Three related features: 1. Dynamic CTA buttons on HeroSimple, CTASection, CallToAction. New shared ctas[] array (text + href + variant + target) replaces the primary/secondary pair. Settings panel gets add/remove/reorder controls. Legacy fields stay readable for backwards compat — first user edit migrates the section onto the new array. 2. Anchor IDs on all layout/section components (Container, Section, BackgroundSection, ColumnLayout, plus 6 section blocks done by parallel subagent, plus Hero/CTA/CallToAction). Anchor input lives in the settings panel with an "auto from heading" button that walks the subtree for the first Heading.text. Renders as id="..." on the outermost element so #anchor URLs resolve. 3. Edit-with-Sitesmith targeted invocation. Right-click → "Ask Sitesmith" and a button at the top of the right-side settings panel both open the modal pre-targeted at the selected node. The node's serialized subtree is sent to the server; system prompt is augmented to require a patch with replace_node. Editor lifts modal state into a new SitesmithContext. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,14 +34,20 @@ export function useSitesmith(siteId: number) {
|
||||
|
||||
useEffect(() => { void refreshEntitlement(); void fetchHistory(); }, [refreshEntitlement, fetchHistory]);
|
||||
|
||||
const send = useCallback(async (userText: string, canvasSummary: string): Promise<SendResult> => {
|
||||
const send = useCallback(async (
|
||||
userText: string,
|
||||
canvasSummary: string,
|
||||
target?: { node_id: string; display_name: string; tree_json: string },
|
||||
): Promise<SendResult> => {
|
||||
if (!whpConfig) return { ok: false, status: 'BLOCKED', message: 'No WHP config' };
|
||||
setMessages((m) => [...m, { role: 'user', content: userText, response_type: null, created_at: new Date().toISOString() }]);
|
||||
const body: Record<string, unknown> = { site_id: siteId, message: userText, canvas_summary: canvasSummary };
|
||||
if (target) body.target = target;
|
||||
const r = await fetch(`${apiBase(whpConfig.apiUrl)}?action=send`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': whpConfig.csrfToken },
|
||||
body: JSON.stringify({ site_id: siteId, message: userText, canvas_summary: canvasSummary }),
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
const j: SendResult = await r.json();
|
||||
void fetchHistory();
|
||||
|
||||
Reference in New Issue
Block a user