aboutsummaryrefslogtreecommitdiff
path: root/apps/web/lib/loadSnap.ts
blob: 2d3cd24e1f633bf5074c75bf7cb23d0e3fa84b3c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { createTLStore, defaultShapeUtils, loadSnapshot } from "tldraw";
import { getCanvasData } from "../app/actions/fetchers";
// import { twitterCardUtil } from "../components/canvas/custom_nodes/twitterCard";
import { twitterCardUtil } from "@/components/canvas/custom_nodes/twittercard";
import { textCardUtil } from "@/components/canvas/custom_nodes/textcard";

export async function loadRemoteSnapshot(id: string) {
	const snapshot = await getCanvasData(id);

	const newStore = createTLStore({
		shapeUtils: [...defaultShapeUtils, twitterCardUtil, textCardUtil],
	});
	loadSnapshot(newStore, snapshot.snapshot);
	return newStore;
}