diff --git a/app/components/Dropdown.tsx b/app/components/Dropdown.tsx
index 90792b5a..eff39f13 100644
--- a/app/components/Dropdown.tsx
+++ b/app/components/Dropdown.tsx
@@ -6,6 +6,7 @@ import {
createReplitProject,
createStackBlitzProject,
getCodeSandboxUrl,
+ getLiveCodesUrl,
} from '../lib/uploadToThirdParty'
export function Dropdown({
@@ -73,6 +74,15 @@ export function Dropdown({
}
}, [html, toast])
+ const openInLiveCodes = useCallback(() => {
+ try {
+ const project = getLiveCodesUrl(html)
+ window.open(project)
+ } catch {
+ toast.addToast({ title: 'There was a problem opening in LiveCodes.' })
+ }
+ }, [html, toast])
+
// const openInCodePen = useCallback(async () => {
// window.open(getCodePenUrl(html))
// }, [html])
@@ -100,6 +110,7 @@ export function Dropdown({
- Open in CodeSandbox
- Open in StackBlitz
- Open in Replit
+ - Open in LiveCodes
{/* - Open in CodePen
*/}
diff --git a/app/lib/uploadToThirdParty.ts b/app/lib/uploadToThirdParty.ts
index 96724777..73ebfc47 100644
--- a/app/lib/uploadToThirdParty.ts
+++ b/app/lib/uploadToThirdParty.ts
@@ -57,6 +57,19 @@ export function getCodeSandboxUrl(html: string) {
return `https://codesandbox.io/api/v1/sandboxes/define?parameters=${project}`
}
+export function getLiveCodesUrl(html: string) {
+ const config = {
+ title: 'Make real from tldraw',
+ description: 'Your AI generated example made at https://makereal.tldraw.com/',
+ markup: {
+ language: 'html',
+ content: html,
+ },
+ }
+ const compressed = LZString.compressToEncodedURIComponent(JSON.stringify(config))
+ return `https://livecodes.io/?x=code/${compressed}`
+}
+
// The following two functions are from
// https://github.com/codesandbox/codesandbox-importers/blob/master/packages/import-utils/src/api/define.17:41:36
// They are licensed under GPLv3 and from my understanding usning them here is fine since we are using GNU Affero General Public License v3.0