Files
site-builder/craft
shadowdaoandClaude Opus 5 1a01834068 feat(site-builder): add domain-confirmed Reset Entire Site
Adds a danger-zone escape hatch below SiteDesignPanel's existing "Reset to
Defaults": blanks every page down to one empty Home, blanks the header and
footer, and resets all design tokens. Guarded by typing the exact site
domain to arm the confirm button.

The brief's setHeader('')/setFooter('') calls were wrong -- both take a
SerializedTreeNode (same tree shape as replaceAllPages), not a craft-state
string; passing '' would have hit treeToCraftState's sanitizeAiTree and
silently fallen back to a generic div-shaped empty canvas instead of a
proper header/footer. Built BLANK_HEADER_TREE/BLANK_FOOTER_TREE (tagged
header/footer) alongside the brief's page tree, and dropped the brief's
literal's extraneous flat-state fields (isCanvas/displayName/custom/hidden/
linkedNodes) that made it need an `as any` cast -- sanitizeAiTree/
flattenTreeForCraft only ever read type/props/nodes.

In standalone mode (no WHP_CONFIG) siteDomain is '', so the entire danger
zone -- not just the button -- is hidden behind `siteDomain &&`, closing off
the empty-string-trivially-matches guard bypass.

Dialog copy states the reset is undoable... is NOT undoable, and that
auto-save (confirmed exactly 30s via TopBar.tsx's setInterval) turns the
blank canvas into the saved draft shortly after, so no false safety-net
claim is made.

Verified load-bearing: reverted the implementation via git stash and
confirmed 3 of 4 new tests fail (the 4th, an absence-only standalone-mode
check, passed vacuously on first draft -- rewritten into a same-test
contrast against the non-standalone case, which does fail on revert).
Split into a second mock-free integration test file
(SiteDesignPanel.reset.integration.test.tsx) after vi.mock's file-scoped
hoisting made a same-file vi.doUnmock silently keep using the mocks --
it exercises the real PageProvider/SiteDesignProvider/treeToCraftState
pipeline end to end via the real editorHarness.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-09 10:17:53 -07:00
..

WHP Site Builder v2

A visual drag-and-drop website builder for WHP, rebuilt from the ground up with Craft.js, React 18, and TypeScript. Replaces the legacy GrapesJS-based editor.

Quick Start

npm install
npm run dev

Opens at http://localhost:5173. The editor runs in standalone mode without WHP integration.

Build and Deploy

# Build production bundle
npm run build

# Deploy to WHP
cp dist/index.html /docker/whp/web/site-builder/editor.html
cp -r dist/js/ /docker/whp/web/site-builder/js/
cp -r dist/css/ /docker/whp/web/site-builder/css/

The PHP wrapper (index.php) injects WHP_CONFIG (user session, CSRF token, site ID) into the HTML before serving.

Architecture

  • Craft.js - React-based visual editor framework (no iframe, direct DOM rendering)
  • Inline styles - All user content uses React CSSProperties, no class-based CSS
  • Component pattern - Each component is a self-contained file with: render logic, settings panel, Craft.js config, and HTML export method
  • 3-panel layout - Left (blocks/pages/layers/assets), Center (canvas with device preview), Right (styles/settings/head)
  • Dark theme - CSS custom properties, Inter font, blue accent

Components (22)

Category Components
Layout Container, Section, ColumnLayout (1-6 cols), BackgroundSection, HeaderZone, FooterZone
Basic Heading (H1-H6), TextBlock, ButtonLink, Navbar, Footer, Divider, Spacer
Media ImageBlock (upload/browse/drag-drop), VideoBlock (YouTube/Vimeo/direct/background)
Sections HeroSimple, FeaturesGrid, CTASection
Forms FormContainer, InputField, TextareaField, FormButton

Features

  • Visual Editor - Drag-and-drop building, real-time preview, responsive device preview (Desktop/Tablet/Mobile)
  • Site Design Tokens - 17 site-wide properties (colors, fonts, radii, nav style) with Basic/Advanced tabs
  • Multi-Page - Unlimited pages with shared Header and Footer across all pages
  • 16 Templates - Pre-built designs across 4 categories (Business, Creative, Personal, Community)
  • Asset Management - Upload, browse, drag-drop, thumbnails, server-side storage via WHP API
  • HTML Export - Full document export with Google Fonts and inline styles
  • Auto-Save - Saves every 30 seconds when connected to WHP
  • Context Menu - Right-click for duplicate, copy, paste, move, delete
  • Keyboard Shortcuts - Undo, redo, delete
  • Layers Panel - Component hierarchy tree view
  • Undo/Redo - Full history support

Key Files

File Purpose
src/main.tsx Entry point, reads WHP_CONFIG
src/App.tsx Editor + providers (EditorConfig, SiteDesign, Pages)
src/components/resolver.ts Component registry (20 components) for serialization
src/editor/EditorShell.tsx 3-panel layout + context menu + keyboard shortcuts
src/editor/Canvas.tsx Craft.js Frame with device switching
src/state/PageContext.tsx Multi-page state + header/footer
src/state/SiteDesignContext.tsx 17 site-wide design tokens
src/templates/definitions.ts 16 template definitions
src/constants/presets.ts Color, font, spacing presets
src/utils/html-export.ts Node-tree to HTML renderer

See CLAUDE.md for full documentation. See FEATURES.md for a complete feature list.