The update editor opens stored blocks through the same cleaning as a save

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
zooqueen
2026-10-16 07:21:13 -07:00
co-authored by Hanzo Dev
parent 74ce359fd5
commit d169a64f9c
+6 -1
View File
@@ -6,6 +6,7 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card"; import { Card } from "@/components/ui/card";
import { DropdownButton } from "@/components/ui/dropdown-button"; import { DropdownButton } from "@/components/ui/dropdown-button";
import { cleanBlocks } from "@/lib/update-blocks";
import { api } from "@/trpc/react"; import { api } from "@/trpc/react";
import type { Block, PartialBlock } from "@blocknote/core"; import type { Block, PartialBlock } from "@blocknote/core";
import type { Update } from "@prisma/client"; import type { Update } from "@prisma/client";
@@ -166,8 +167,12 @@ const UpdatesEditor = ({
]; ];
const [title, setTitle] = useState<string>(update?.title ?? ""); const [title, setTitle] = useState<string>(update?.title ?? "");
// Stored blocks are loaded through the same cleaning the server applies on
// save, so an update written before that cleaning opens without unsafe links.
const [content, setContent] = useState<Block[]>( const [content, setContent] = useState<Block[]>(
(update?.content as Block[]) ?? defaultContent, update?.content
? (cleanBlocks(update.content) as unknown as Block[])
: defaultContent,
); );
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);