diff --git a/openspec/changes/add-custom-html-block/.openspec.yaml b/openspec/changes/add-custom-html-block/.openspec.yaml new file mode 100644 index 0000000..eb2b21e --- /dev/null +++ b/openspec/changes/add-custom-html-block/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-12-02 diff --git a/openspec/changes/add-custom-html-block/design.md b/openspec/changes/add-custom-html-block/design.md new file mode 100644 index 0000000..b305522 --- /dev/null +++ b/openspec/changes/add-custom-html-block/design.md @@ -0,0 +1,41 @@ +# Design + +The full design is `docs/superpowers/specs/2026-12-02-custom-html-block-design.md` (approved 2026-12-02). This file records the technical decisions. + +## Context + +- Pages store their blocks as JSON in `cms_page.blocks`. `CmsBlockValidator` in services-counter checks the blocks, and mobile-api passes them to the portal unchanged. +- The portal's `middleware.ts` gives every page and API response a per-request nonce Content-Security-Policy. An `srcdoc` frame would inherit that policy and block the pasted scripts, inline styles and CDN links. So the pasted HTML needs its own response with its own policy. +- The public page `/p/[company]/[slug]` renders on the server. `routeGuard.isPublicPath` admits only `^/p/[^/]+/[^/]+$` today. + +## Goals / Non-Goals + +**Goals:** +- Pasted HTML renders as designed. +- It runs with an opaque origin on every path, including a direct visit to the frame address. + +**Non-Goals:** +- SEO for the framed content. +- Working forms inside it. +- An HTML editor. + +## Decisions + +1. **Route handlers, not pages.** `app/p/[company]/[slug]/frame/[block]/route.ts` and `app/pages/[id]/preview/frame/[block]/route.ts` return `text/html` directly. They reuse the server helpers that the public page (published read) and the preview (admin read with the session token) already use. +2. **Sandbox in two places.** + - The response header: `Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox; frame-ancestors 'self'`. This covers a direct visit. + - The `