Visual text editor; Cards, FAQ and HTML blocks; block anchors

The text editor (Tiptap) only produces simple HTML: headings, bold,
italic, strikethrough, links, lists, pull quotes, lines. Layouts that
were hand-written HTML in text blocks get their own blocks (Cards with
pictures or numbered steps, FAQ), one-offs and embeds go in an HTML
block, and every block can have an anchor for #links. Text blocks get
alignment and a small (footnote) size.

Existing text blocks the editor can't represent become HTML blocks that
render exactly as before (migration, and backup import for old files);
text that is only centred becomes centred text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
This commit is contained in:
agent 2026-10-26 12:58:15 +00:00
parent 72f8898925
commit f86c2251dc
17 changed files with 532 additions and 72 deletions

View file

@ -7,6 +7,8 @@ import {
validateSiteExport,
type SiteExport
} from '$lib/exportImport';
import { upgradeLegacyBlocks } from '$shared/richText';
import type { ContentBlock } from '$lib/types';
export const POST: RequestHandler = async ({ request, locals }) => {
let body: SiteExport;
@ -54,7 +56,8 @@ export const POST: RequestHandler = async ({ request, locals }) => {
// 2. Import pages
for (const page of body.pages) {
try {
const blocks = restorePlaceholders(page.blocks, keyToUrl);
// Files exported before the visual editor may hold raw HTML in text blocks.
const blocks = upgradeLegacyBlocks(restorePlaceholders(page.blocks, keyToUrl) as ContentBlock[]);
// Try to find existing page by slug
let existing;