fix
This commit is contained in:
+22
-24
@@ -11,13 +11,11 @@ import { Globe2Icon, PlusIcon, Trash2Icon, XIcon, ChevronDownIcon, ChevronUpIcon
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "./ui/select";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Input } from "./ui/input";
|
||||
import { Separator } from "./ui/separator";
|
||||
import { Alert } from "./ui/alert";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { uploadPageImage, getImagePreviewUrl } from "@/lib/pages/actions";
|
||||
import { ImageUploader } from "@/components/image-uploader";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
|
||||
export type EditorData = {
|
||||
title: string;
|
||||
@@ -319,13 +317,13 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
<AutoResizeTextarea
|
||||
className="w-full bg-transparent resize-none outline-none leading-relaxed placeholder:text-muted-foreground"
|
||||
placeholder="Start writing..."
|
||||
value={(block.content as any).text ?? ""}
|
||||
value={(block.content as { type: "PARAGRAPH"; text: string }).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "PARAGRAPH", text: e.target.value })}
|
||||
/>
|
||||
);
|
||||
|
||||
case "HEADING":
|
||||
const level = (block.content as any).level;
|
||||
const level = (block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).level;
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -339,12 +337,12 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
}
|
||||
)}
|
||||
placeholder="Heading"
|
||||
value={(block.content as any).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "HEADING", text: e.target.value, level: (block.content as any).level ?? 2 })}
|
||||
value={(block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "HEADING", text: e.target.value, level: (block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).level ?? 2 })}
|
||||
/>
|
||||
<Select
|
||||
value={String((block.content as any).level ?? 2)}
|
||||
onValueChange={(v) => onChange({ type: "HEADING", text: (block.content as any).text ?? "", level: Number(v) as 1 | 2 | 3 })}
|
||||
value={String((block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).level ?? 2)}
|
||||
onValueChange={(v) => onChange({ type: "HEADING", text: (block.content as { type: "HEADING"; text: string; level: 1 | 2 | 3 }).text ?? "", level: Number(v) as 1 | 2 | 3 })}
|
||||
>
|
||||
<SelectTrigger className="w-16 h-7 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<SelectValue />
|
||||
@@ -364,14 +362,14 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
<AutoResizeTextarea
|
||||
className="w-full bg-transparent resize-none outline-none leading-relaxed placeholder:text-muted-foreground"
|
||||
placeholder="Quote text..."
|
||||
value={(block.content as any).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "QUOTE", text: e.target.value, author: (block.content as any).author })}
|
||||
value={(block.content as { type: "QUOTE"; text: string; author?: string }).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "QUOTE", text: e.target.value, author: (block.content as { type: "QUOTE"; text: string; author?: string }).author })}
|
||||
/>
|
||||
<input
|
||||
className="w-full bg-transparent outline-none text-sm text-muted-foreground placeholder:text-muted-foreground/60"
|
||||
placeholder="— Author"
|
||||
value={(block.content as any).author ?? ""}
|
||||
onChange={(e) => onChange({ type: "QUOTE", text: (block.content as any).text, author: e.target.value })}
|
||||
value={(block.content as { type: "QUOTE"; text: string; author?: string }).author ?? ""}
|
||||
onChange={(e) => onChange({ type: "QUOTE", text: (block.content as { type: "QUOTE"; text: string; author?: string }).text, author: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -383,14 +381,14 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
<input
|
||||
className="w-full bg-transparent outline-none text-sm font-medium placeholder:text-muted-foreground"
|
||||
placeholder="Callout title"
|
||||
value={(block.content as any).title ?? ""}
|
||||
onChange={(e) => onChange({ type: "CALLOUT", title: e.target.value, text: (block.content as any).text ?? "" })}
|
||||
value={(block.content as { type: "CALLOUT"; title: string; text: string }).title ?? ""}
|
||||
onChange={(e) => onChange({ type: "CALLOUT", title: e.target.value, text: (block.content as { type: "CALLOUT"; title: string; text: string }).text ?? "" })}
|
||||
/>
|
||||
<AutoResizeTextarea
|
||||
className="w-full bg-transparent resize-none outline-none text-sm leading-relaxed text-muted-foreground placeholder:text-muted-foreground/60"
|
||||
placeholder="Callout text..."
|
||||
value={(block.content as any).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "CALLOUT", title: (block.content as any).title ?? "", text: e.target.value })}
|
||||
value={(block.content as { type: "CALLOUT"; title: string; text: string }).text ?? ""}
|
||||
onChange={(e) => onChange({ type: "CALLOUT", title: (block.content as { type: "CALLOUT"; title: string; text: string }).title ?? "", text: e.target.value })}
|
||||
/>
|
||||
</Alert>
|
||||
);
|
||||
@@ -409,10 +407,10 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
return <Separator />;
|
||||
|
||||
case "LIST":
|
||||
return <ListEditor content={block.content as any} onChange={(c) => onChange(c)} />;
|
||||
return <ListEditor content={block.content as { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }} onChange={(c) => onChange(c)} />;
|
||||
|
||||
case "TABLE":
|
||||
return <TableEditor content={block.content as any} onChange={(c) => onChange(c)} />;
|
||||
return <TableEditor content={block.content as { type: "TABLE"; headers: string[]; rows: string[][] }} onChange={(c) => onChange(c)} />;
|
||||
|
||||
case "LINK":
|
||||
return (
|
||||
@@ -422,12 +420,12 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
<input
|
||||
className="w-full bg-transparent outline-none text-sm"
|
||||
placeholder="Link label"
|
||||
value={(block.content as any).label ?? ""}
|
||||
value={(block.content as { type: "LINK"; label: string; href: string }).label ?? ""}
|
||||
onChange={(e) =>
|
||||
onChange({
|
||||
type: "LINK",
|
||||
label: e.target.value,
|
||||
href: (block.content as any).href ?? "",
|
||||
href: (block.content as { type: "LINK"; label: string; href: string }).href ?? "",
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -435,11 +433,11 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
<input
|
||||
className="w-full bg-transparent outline-none text-sm text-muted-foreground"
|
||||
placeholder="URL"
|
||||
value={(block.content as any).href ?? ""}
|
||||
value={(block.content as { type: "LINK"; label: string; href: string }).href ?? ""}
|
||||
onChange={(e) =>
|
||||
onChange({
|
||||
type: "LINK",
|
||||
label: (block.content as any).label ?? "",
|
||||
label: (block.content as { type: "LINK"; label: string; href: string }).label ?? "",
|
||||
href: e.target.value,
|
||||
})
|
||||
}
|
||||
@@ -453,7 +451,7 @@ function BlockInput({ block, onChange, previewUrls, onPreviewReady }: { block: B
|
||||
}
|
||||
}
|
||||
|
||||
function ListEditor({ content, onChange }: { content: { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }; onChange: (c: any) => void }) {
|
||||
function ListEditor({ content, onChange }: { content: { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }; onChange: (c: { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }) => void }) {
|
||||
const items = content.items ?? [""];
|
||||
|
||||
function updateItem(index: number, value: string) {
|
||||
@@ -531,7 +529,7 @@ function ListEditor({ content, onChange }: { content: { type: "LIST"; style: "BU
|
||||
);
|
||||
}
|
||||
|
||||
function TableEditor({ content, onChange }: { content: { type: "TABLE"; headers: string[]; rows: string[][] }; onChange: (c: any) => void }) {
|
||||
function TableEditor({ content, onChange }: { content: { type: "TABLE"; headers: string[]; rows: string[][] }; onChange: (c: { type: "TABLE"; headers: string[]; rows: string[][] }) => void }) {
|
||||
const headers = content.headers ?? ["Column 1"];
|
||||
const rows = content.rows ?? [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user