forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-embed.tsx
More file actions
37 lines (31 loc) · 990 Bytes
/
Copy pathcode-embed.tsx
File metadata and controls
37 lines (31 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sdk from "@stackblitz/sdk";
import { useEffect, useRef } from "react";
export function CodeEmbed() {
const codeEmbedRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const embedProject = async () => {
if (codeEmbedRef.current) {
const vm = await sdk.embedProjectId(codeEmbedRef.current, "stackblitz-starters-65j6at", {
forceEmbedLayout: true,
openFile: [],
height: 600,
view: "default",
terminalHeight: 0,
hideDevTools: true,
hideExplorer: true,
hideNavigation: true,
});
vm.editor.openFile("app/page.tsx");
await vm.applyFsDiff({ destroy: [".env"], create: {} });
await vm.applyFsDiff({
create: {
".env": "COPILOT_CLOUD_PUBLIC_API_KEY=123"
},
destroy: [],
});
}
};
embedProject();
}, []);
return <div ref={codeEmbedRef} id="code_embed_123" style={{ height: 800 }} />;
}