mirror of
https://github.com/hanzoai/captable.git
synced 2026-10-16 14:21:29 +00:00
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:
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user