diff --git a/bun.lockb b/bun.lockb old mode 100755 new mode 100644 diff --git a/package.json b/package.json index a8956340..a02170e4 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "@tscircuit/3d-viewer": "^0.0.32", "@tscircuit/footprinter": "^0.0.68", "@tscircuit/pcb-viewer": "^1.10.5", + "@types/file-saver": "^2.0.7", "@types/ms": "^0.7.34", "@typescript/ata": "^0.9.7", "@valtown/codemirror-ts": "^2.2.0", @@ -66,6 +67,7 @@ "easyeda": "^0.0.32", "embla-carousel-react": "^8.3.0", "fflate": "^0.8.2", + "file-saver": "^2.0.5", "immer": "^10.1.1", "input-otp": "^1.2.4", "jose": "^5.9.3", diff --git a/src/components/CodeAndPreview.tsx b/src/components/CodeAndPreview.tsx index d4c44c98..3c7b9ff6 100644 --- a/src/components/CodeAndPreview.tsx +++ b/src/components/CodeAndPreview.tsx @@ -98,6 +98,7 @@ export function CodeAndPreview({ snippet }: Props) { return (
@@ -20,14 +31,15 @@ export function DownloadButtonAndMenu({ className }: { className?: string }) { - - - Download TSX - - tsx - - - + + downloadCircuitJson( + circuitJson, + snippetUnscopedName || "circuit" + ".json", + ) + } + > Download Circuit JSON diff --git a/src/components/EditorNav.tsx b/src/components/EditorNav.tsx index 07872924..8fda04a4 100644 --- a/src/components/EditorNav.tsx +++ b/src/components/EditorNav.tsx @@ -24,6 +24,7 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" +import { useRunTsx } from "@/hooks/use-run-tsx" import { OpenInNewWindowIcon } from "@radix-ui/react-icons" import { encodeTextToUrlHash } from "@/lib/encodeTextToUrlHash" import { Snippet } from "fake-snippets-api/lib/db/schema" @@ -34,6 +35,7 @@ import { TypeBadge } from "./TypeBadge" import { SnippetLink } from "./SnippetLink" export default function EditorNav({ + circuitJson, snippet, code, hasUnsavedChanges, @@ -42,6 +44,7 @@ export default function EditorNav({ onSave, isSaving, }: { + circuitJson: any snippet: Snippet code: string hasUnsavedChanges: boolean @@ -111,7 +114,11 @@ export default function EditorNav({ Edit with AI - + - +
Code