diff --git a/src/app/api/preview/route.ts b/src/app/api/preview/route.ts new file mode 100644 index 0000000..c3eba20 --- /dev/null +++ b/src/app/api/preview/route.ts @@ -0,0 +1,12 @@ +import { NextRequest, NextResponse } from 'next/server'; + +export async function POST(request: NextRequest) { + const body = await request.json(); + const { content } = body; + + if (typeof content !== 'string') { + return NextResponse.json({ error: 'content must be a string' }, { status: 400 }); + } + + return NextResponse.json({ html: content }); +} diff --git a/src/app/editor/page.tsx b/src/app/editor/page.tsx index af12022..986a27d 100644 --- a/src/app/editor/page.tsx +++ b/src/app/editor/page.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react'; import dynamic from 'next/dynamic'; +import { sanitizeHtml } from '@/utils/sanitize'; const RichContentEditor = dynamic( () => import('@/components/editor/RichContentEditor').then((mod) => mod.RichContentEditor), @@ -15,25 +16,35 @@ const RichContentEditor = dynamic( export default function EditorPage() { const [content, setContent] = useState('
Start editing...
'); + const [isPreviewMode, setIsPreviewMode] = useState(false); return (
- {content}
-
-