From 434822c8049d0a127fad172e1b0a24a9dadc7249 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Tue, 5 Mar 2024 11:42:26 +0000 Subject: [PATCH 1/3] update for 2.0 --- app/PreviewShape/PreviewShape.tsx | 2 +- app/components/APIKeyInput.tsx | 2 +- app/components/Dropdown.tsx | 2 +- app/components/LinkArea.tsx | 2 +- app/components/UrlLinkButton.tsx | 2 +- app/hooks/useMakeReal.ts | 2 +- app/lib/getSelectionAsText.ts | 2 +- app/lib/makeReal.ts | 2 +- app/makereal.tldraw.com/page.tsx | 4 +- app/page.tsx | 113 +++++++++++++ app/prompt.ts | 29 ++-- package-lock.json | 272 +++++++++++++----------------- package.json | 2 +- 13 files changed, 254 insertions(+), 182 deletions(-) create mode 100644 app/page.tsx diff --git a/app/PreviewShape/PreviewShape.tsx b/app/PreviewShape/PreviewShape.tsx index 5addfbf..b82a078 100644 --- a/app/PreviewShape/PreviewShape.tsx +++ b/app/PreviewShape/PreviewShape.tsx @@ -11,7 +11,7 @@ import { useIsEditing, useToasts, useValue, -} from '@tldraw/tldraw' +} from 'tldraw' import { useEffect } from 'react' import { Dropdown } from '../components/Dropdown' import { LINK_HOST, PROTOCOL } from '../lib/hosts' diff --git a/app/components/APIKeyInput.tsx b/app/components/APIKeyInput.tsx index 67226a3..0d002a5 100644 --- a/app/components/APIKeyInput.tsx +++ b/app/components/APIKeyInput.tsx @@ -1,4 +1,4 @@ -import { TldrawUiIcon, useBreakpoint, useEditor, useValue } from '@tldraw/tldraw' +import { TldrawUiIcon, useBreakpoint, useEditor, useValue } from 'tldraw' import { ChangeEvent, useCallback, useState } from 'react' import { setTimeout } from 'timers' diff --git a/app/components/Dropdown.tsx b/app/components/Dropdown.tsx index 90792b5..cc992b4 100644 --- a/app/components/Dropdown.tsx +++ b/app/components/Dropdown.tsx @@ -1,6 +1,6 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu' import sdk from '@stackblitz/sdk' -import { stopEventPropagation, useToasts } from '@tldraw/tldraw' +import { stopEventPropagation, useToasts } from 'tldraw' import { useCallback } from 'react' import { createReplitProject, diff --git a/app/components/LinkArea.tsx b/app/components/LinkArea.tsx index 743dbdb..b5aa4e3 100644 --- a/app/components/LinkArea.tsx +++ b/app/components/LinkArea.tsx @@ -1,4 +1,4 @@ -import { useBreakpoint, useEditor, useValue } from '@tldraw/tldraw' +import { useBreakpoint, useEditor, useValue } from 'tldraw' import { track } from '@vercel/analytics/react' export function LinkArea() { diff --git a/app/components/UrlLinkButton.tsx b/app/components/UrlLinkButton.tsx index 5f42e8e..fc18d66 100644 --- a/app/components/UrlLinkButton.tsx +++ b/app/components/UrlLinkButton.tsx @@ -1,6 +1,6 @@ 'use client' -import { TldrawUiIcon, stopEventPropagation, useToasts } from '@tldraw/tldraw' +import { TldrawUiIcon, stopEventPropagation, useToasts } from 'tldraw' export function UrlLinkButton({ uploadUrl }: { uploadUrl: string }) { const toast = useToasts() diff --git a/app/hooks/useMakeReal.ts b/app/hooks/useMakeReal.ts index 6f2dabd..5234aac 100644 --- a/app/hooks/useMakeReal.ts +++ b/app/hooks/useMakeReal.ts @@ -1,4 +1,4 @@ -import { useEditor, useToasts } from '@tldraw/tldraw' +import { useEditor, useToasts } from 'tldraw' import { track } from '@vercel/analytics/react' import { useCallback } from 'react' import { makeReal } from '../lib/makeReal' diff --git a/app/lib/getSelectionAsText.ts b/app/lib/getSelectionAsText.ts index c584c0d..1f8b773 100644 --- a/app/lib/getSelectionAsText.ts +++ b/app/lib/getSelectionAsText.ts @@ -1,4 +1,4 @@ -import { Editor, TLGeoShape, TLTextShape } from '@tldraw/tldraw' +import { Editor, TLGeoShape, TLTextShape } from 'tldraw' export function getSelectionAsText(editor: Editor) { const selectedShapeIds = editor.getSelectedShapeIds() diff --git a/app/lib/makeReal.ts b/app/lib/makeReal.ts index 5a0c63a..f6c4153 100644 --- a/app/lib/makeReal.ts +++ b/app/lib/makeReal.ts @@ -1,4 +1,4 @@ -import { Editor, createShapeId, getSvgAsImage } from '@tldraw/tldraw' +import { Editor, createShapeId, getSvgAsImage } from 'tldraw' import { track } from '@vercel/analytics/react' import { PreviewShape } from '../PreviewShape/PreviewShape' import { addGridToSvg } from './addGridToSvg' diff --git a/app/makereal.tldraw.com/page.tsx b/app/makereal.tldraw.com/page.tsx index cf06aa5..de7f695 100644 --- a/app/makereal.tldraw.com/page.tsx +++ b/app/makereal.tldraw.com/page.tsx @@ -2,7 +2,7 @@ /* eslint-disable react-hooks/rules-of-hooks */ 'use client' -import '@tldraw/tldraw/tldraw.css' +import 'tldraw/tldraw.css' import dynamic from 'next/dynamic' import { PreviewShapeUtil } from '../PreviewShape/PreviewShape' import { APIKeyInput } from '../components/APIKeyInput' @@ -10,7 +10,7 @@ import { ExportButton } from '../components/ExportButton' import { LinkArea } from '../components/LinkArea' -const Tldraw = dynamic(async () => (await import('@tldraw/tldraw')).Tldraw, { +const Tldraw = dynamic(async () => (await import('tldraw')).Tldraw, { ssr: false, }) diff --git a/app/page.tsx b/app/page.tsx new file mode 100644 index 0000000..4fe54fa --- /dev/null +++ b/app/page.tsx @@ -0,0 +1,113 @@ +"use client"; + +import dynamic from "next/dynamic"; +import "tldraw/tldraw.css"; +import { useEditor } from "tldraw"; +import { getSvgAsImage } from "@/lib/getSvgAsImage"; +import { blobToBase64 } from "@/lib/blobToBase64"; +import React, { useEffect, useState } from "react"; +import ReactDOM from "react-dom"; +import { PreviewModal } from "@/components/PreviewModal"; + +const Tldraw = dynamic(async () => (await import("tldraw")).Tldraw, { + ssr: false, +}); + +export default function Home() { + const [html, setHtml] = useState(null); + + useEffect(() => { + const listener = (e: KeyboardEvent) => { + if (e.key === "Escape") { + setHtml(null); + } + }; + window.addEventListener("keydown", listener); + + return () => { + window.removeEventListener("keydown", listener); + }; + }); + + return ( + <> +
+ + + +
+ {html && + ReactDOM.createPortal( +
setHtml(null)} + > + +
, + document.body + )} + + ); +} + +function ExportButton({ setHtml }: { setHtml: (html: string) => void }) { + const editor = useEditor(); + const [loading, setLoading] = useState(false); + // A tailwind styled button that is pinned to the bottom right of the screen + return ( + + ); +} diff --git a/app/prompt.ts b/app/prompt.ts index 05471f9..6539644 100644 --- a/app/prompt.ts +++ b/app/prompt.ts @@ -1,24 +1,17 @@ -export const OPEN_AI_SYSTEM_PROMPT = `You are an expert web developer. You are an expert in HTML, JavaScript, and CSS. You are especially expert in creating designs using Tailwind CSS. +export const OPEN_AI_SYSTEM_PROMPT = `You are an expert web developer who specializes in building working website prototypes from low-fidelity wireframes. Your job is to accept low-fidelity designs and turn them into interactive and responsive working prototypes. When sent new designs, you should reply with your best attempt at a high fidelity working prototype as a single HTML file. -Your job is to -- accept designs (low-fidelity wireframes, sketches, compositions, and user experience notes) -- return working single-page web apps that follow the designs +Use tailwind CSS for styling. If you must use other CSS, place it in a style tag. -Instructions: -- Use Tailwind CSS for styling. -- Use Google fonts to pull in any open source fonts you require. -- Use Unsplash to pull in any images you require. -- Use Unpkg to pull in any JavaScript or CSS libraries you require. -- Respond with a single HTML file that includes all necessary CSS and JavaScript. +Put any JavaScript in a script tag. Use unpkg or skypack to import any required JavaScript dependencies. Use Google fonts to pull in any open source fonts you require. If you have any images, load them from Unsplash or use solid colored rectangles as placeholders. -Tips: -- Markup in the color red is probably an annotation -- Avoid "etc etc" sections. Create placeholder content instead. -- Do not include any comments in your code! -- Make your web apps are more beautiful, professional, complete, and high fidelity than the designs you are given. -` +The designs may include flow charts, diagrams, labels, arrows, sticky notes, screenshots of other applications, or even previous designs. Treat all of these as references for your prototype. Use your best judgement to determine what is an annotation and what should be included in the final result. Treat anything in the color red as an annotation rather than part of the design. Do NOT include any red elements or any other annotations in your final result. -export const OPENAI_USER_PROMPT = 'Please create a web app from these designs.' +Your prototype should look and feel much more complete and advanced than the wireframes provided. Flesh it out, make it real! Try your best to figure out what the designer wants and make it happen. If there are any questions or underspecified features, use what you know about applications, user experience, and website design patterns to "fill in the blanks". If you're unsure of how the designs should work, take a guess—it's better for you to get it wrong than to leave things incomplete. + +Remember: you love your designers and want them to be happy. The more complete and impressive your prototype, the happier they will be. Good luck, you've got this!` + +export const OPENAI_USER_PROMPT = + 'Here are the latest wireframes. Return a single HMTL file based on these wireframes and notes. Send back just the HTML file contents.' export const OPENAI_USER_PROMPT_WITH_PREVIOUS_DESIGN = - 'Please create a webapp from these designs. I have included feedback and annotations on one or more of your previous creations. Try to incorporate my feedback and annotations into your new web app.' + 'Here are the latest wireframes. There are also some previous outputs here. Could you make a new website based on these wireframes and notes and send back just the html file?' diff --git a/package-lock.json b/package-lock.json index 849a054..e51462d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6", "@stackblitz/sdk": "^1.9.0", - "@tldraw/tldraw": "^2.0.0-canary.2211ca0063d6", "@vercel/analytics": "^1.1.1", "@vercel/blob": "^0.15.1", "@vercel/kv": "^1.0.0", @@ -22,7 +21,8 @@ "next": "14.0.1", "prettier": "^3.1.0", "react": "^18", - "react-dom": "^18" + "react-dom": "^18", + "tldraw": "^2.0.0" }, "devDependencies": { "@types/node": "^20", @@ -1707,157 +1707,6 @@ "tslib": "^2.4.0" } }, - "node_modules/@tldraw/editor": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/editor/-/editor-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-6Wy8PcjkEXoo7yaq9qbAkK+pq2ZhCJCh3NxEqJY+3A273bhzdTIFKpDSeURgsYly/e9RQ4wikbTVMVF0V+Lx0A==", - "dependencies": { - "@tldraw/state": "2.0.0-canary.2211ca0063d6", - "@tldraw/store": "2.0.0-canary.2211ca0063d6", - "@tldraw/tlschema": "2.0.0-canary.2211ca0063d6", - "@tldraw/utils": "2.0.0-canary.2211ca0063d6", - "@tldraw/validate": "2.0.0-canary.2211ca0063d6", - "@types/core-js": "^2.5.5", - "@use-gesture/react": "^10.2.27", - "classnames": "^2.3.2", - "core-js": "^3.31.1", - "eventemitter3": "^4.0.7", - "idb": "^7.1.1", - "is-plain-object": "^5.0.0", - "lodash.throttle": "^4.1.1", - "lodash.uniq": "^4.5.0", - "nanoid": "4.0.2" - }, - "peerDependencies": { - "react": "^18", - "react-dom": "^18" - } - }, - "node_modules/@tldraw/editor/node_modules/nanoid": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz", - "integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.js" - }, - "engines": { - "node": "^14 || ^16 || >=18" - } - }, - "node_modules/@tldraw/state": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/state/-/state-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-nZLg7jJdy2IZ6vMKVNBTM0ejt5B++QAyrQiieuTSej/fmj9yJSSE/54RsVWUCXy3tjAaogedWFZon/S0pALi/A==", - "peerDependencies": { - "react": "^18" - } - }, - "node_modules/@tldraw/store": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/store/-/store-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-sfrHLni1OFqmfhlzyCMEzL6K6RlGIMrNBGMPQdkK6gFnsvRtIIcfVsgK0P95Rg6F+V84/WS0WTnwoJ6MeKUP3Q==", - "dependencies": { - "@tldraw/state": "2.0.0-canary.2211ca0063d6", - "@tldraw/utils": "2.0.0-canary.2211ca0063d6", - "lodash.isequal": "^4.5.0", - "nanoid": "4.0.2" - }, - "peerDependencies": { - "react": "^18" - } - }, - "node_modules/@tldraw/store/node_modules/nanoid": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz", - "integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.js" - }, - "engines": { - "node": "^14 || ^16 || >=18" - } - }, - "node_modules/@tldraw/tldraw": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/tldraw/-/tldraw-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-JJGny6p6kZ78MJ/NszPSZ7ZMxhvugeW+TQJVdYNOEzDXFLSa2q7c58zo1nUJYEvWGgRZdWkCV+Qb6kCNwDD/gQ==", - "dependencies": { - "@radix-ui/react-alert-dialog": "^1.0.5", - "@radix-ui/react-context-menu": "^2.1.5", - "@radix-ui/react-dialog": "^1.0.5", - "@radix-ui/react-dropdown-menu": "^2.0.6", - "@radix-ui/react-popover": "^1.0.7", - "@radix-ui/react-select": "^1.2.0", - "@radix-ui/react-slider": "^1.1.0", - "@radix-ui/react-toast": "^1.1.1", - "@tldraw/editor": "2.0.0-canary.2211ca0063d6", - "canvas-size": "^1.2.6", - "classnames": "^2.3.2", - "hotkeys-js": "^3.11.2", - "lz-string": "^1.4.4" - }, - "peerDependencies": { - "react": "^18", - "react-dom": "^18" - } - }, - "node_modules/@tldraw/tlschema": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/tlschema/-/tlschema-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-zhUY25v5JVB2YG/Ozh9UJtSFzEZb+V2/fN/jjkNK28Rip3iZBiOj1IOSgpzuOtbKYyLvsKd6LzL8UmsbxRxyzw==", - "dependencies": { - "@tldraw/state": "2.0.0-canary.2211ca0063d6", - "@tldraw/store": "2.0.0-canary.2211ca0063d6", - "@tldraw/utils": "2.0.0-canary.2211ca0063d6", - "@tldraw/validate": "2.0.0-canary.2211ca0063d6", - "nanoid": "4.0.2" - }, - "peerDependencies": { - "react": "^18" - } - }, - "node_modules/@tldraw/tlschema/node_modules/nanoid": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz", - "integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.js" - }, - "engines": { - "node": "^14 || ^16 || >=18" - } - }, - "node_modules/@tldraw/utils": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/utils/-/utils-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-TV/F0FMTa8VneNVnScG/9FcrHx3RZ2P34xCjJXdekuiQByMNjWQ3ZIRzt5UYWHg1L1W6xTQFJtx91lMG4gt9bA==" - }, - "node_modules/@tldraw/validate": { - "version": "2.0.0-canary.2211ca0063d6", - "resolved": "https://registry.npmjs.org/@tldraw/validate/-/validate-2.0.0-canary.2211ca0063d6.tgz", - "integrity": "sha512-gzsVh085zsDOD0L98zyJX3LEnF0w7Ti8Rz0rGjyaunJXVMd0U6lB0QC3W1YCuZ7a2ciOdy7EZ/kCh7+KTUm4zA==", - "dependencies": { - "@tldraw/utils": "2.0.0-canary.2211ca0063d6" - } - }, "node_modules/@tootallnate/once": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", @@ -6651,6 +6500,123 @@ "node": ">=0.8" } }, + "node_modules/tldraw": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tldraw/-/tldraw-2.0.0.tgz", + "integrity": "sha512-Q0rQ9pMhQxt+SZbLpnieZhfUFWuRNDabxbSCPlmBk7IMYq7bLrJMSARpM4fQesD/IfTNPzrQPS1dzteFBK3FaA==", + "dependencies": { + "@radix-ui/react-alert-dialog": "^1.0.5", + "@radix-ui/react-context-menu": "^2.1.5", + "@radix-ui/react-dialog": "^1.0.5", + "@radix-ui/react-dropdown-menu": "^2.0.6", + "@radix-ui/react-popover": "^1.0.7", + "@radix-ui/react-select": "^1.2.0", + "@radix-ui/react-slider": "^1.1.0", + "@radix-ui/react-toast": "^1.1.1", + "@tldraw/editor": "2.0.0", + "canvas-size": "^1.2.6", + "classnames": "^2.3.2", + "hotkeys-js": "^3.11.2", + "lz-string": "^1.4.4" + }, + "peerDependencies": { + "react": "^18", + "react-dom": "^18" + } + }, + "node_modules/tldraw/node_modules/@tldraw/editor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tldraw/editor/-/editor-2.0.0.tgz", + "integrity": "sha512-LfZr09NctyeaQr17HMM9ZZzTxMY2k2h9Qk/RKUwWnw//kidn65r/ODsgtnViDDrSymBA6zw9IlrzIENBMnczPA==", + "dependencies": { + "@tldraw/state": "2.0.0", + "@tldraw/store": "2.0.0", + "@tldraw/tlschema": "2.0.0", + "@tldraw/utils": "2.0.0", + "@tldraw/validate": "2.0.0", + "@types/core-js": "^2.5.5", + "@use-gesture/react": "^10.2.27", + "classnames": "^2.3.2", + "core-js": "^3.31.1", + "eventemitter3": "^4.0.7", + "idb": "^7.1.1", + "is-plain-object": "^5.0.0", + "lodash.throttle": "^4.1.1", + "lodash.uniq": "^4.5.0", + "nanoid": "4.0.2" + }, + "peerDependencies": { + "react": "^18", + "react-dom": "^18" + } + }, + "node_modules/tldraw/node_modules/@tldraw/state": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tldraw/state/-/state-2.0.0.tgz", + "integrity": "sha512-MaD8bVRouQ69OsgySDpFBNcGw7nhI1pc0vf/0Ryl2cMIo0lztPKj0mfgm+cU+dFYxZLdeEi83OOxk6uH6RZAnQ==", + "peerDependencies": { + "react": "^18" + } + }, + "node_modules/tldraw/node_modules/@tldraw/store": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tldraw/store/-/store-2.0.0.tgz", + "integrity": "sha512-2z+DF/eEgr/ruIzHpbO8VgtYl2gFjALK/LDm/fYDvi1DTUUvZtG/NN+9gSNf4UtsgVbjHJUupsB8spCCQ3QjdA==", + "dependencies": { + "@tldraw/state": "2.0.0", + "@tldraw/utils": "2.0.0", + "lodash.isequal": "^4.5.0", + "nanoid": "4.0.2" + }, + "peerDependencies": { + "react": "^18" + } + }, + "node_modules/tldraw/node_modules/@tldraw/tlschema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tldraw/tlschema/-/tlschema-2.0.0.tgz", + "integrity": "sha512-ylV+LhqOa5NULFt5LMvd78oQvx4xi4yB2Tz0PZnZ6kB840iTitlxI98qwXUIlXVBeKAgmhssvtzG26BAACa9Wg==", + "dependencies": { + "@tldraw/state": "2.0.0", + "@tldraw/store": "2.0.0", + "@tldraw/utils": "2.0.0", + "@tldraw/validate": "2.0.0", + "nanoid": "4.0.2" + }, + "peerDependencies": { + "react": "^18" + } + }, + "node_modules/tldraw/node_modules/@tldraw/utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tldraw/utils/-/utils-2.0.0.tgz", + "integrity": "sha512-8EKrAOMlhO7fPDJMFdGEVdYzR/Enc9K5PBSWkiZGw4jWXbe3e828xk6m/sJ/iDBRZzdPPn7UnZPhY1mQ/ONgig==" + }, + "node_modules/tldraw/node_modules/@tldraw/validate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tldraw/validate/-/validate-2.0.0.tgz", + "integrity": "sha512-bnSEtYnr/+i/B5ej0IHshAiJnRFa3SgIHXI57b/Cctw17kdidMhQLokTPlUaWOzcFvySaGYqmO2aPo3Ede25jw==", + "dependencies": { + "@tldraw/utils": "2.0.0" + } + }, + "node_modules/tldraw/node_modules/nanoid": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz", + "integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.js" + }, + "engines": { + "node": "^14 || ^16 || >=18" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/package.json b/package.json index ca95ac0..46ec911 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6", "@stackblitz/sdk": "^1.9.0", - "@tldraw/tldraw": "^2.0.0-canary.2211ca0063d6", + "tldraw": "^2.0.0", "@vercel/analytics": "^1.1.1", "@vercel/blob": "^0.15.1", "@vercel/kv": "^1.0.0", From e07ece6fc32119ffdfb194cb6ff6abfb5423e44c Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Tue, 5 Mar 2024 11:49:36 +0000 Subject: [PATCH 2/3] Update makeReal.ts --- app/lib/makeReal.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/lib/makeReal.ts b/app/lib/makeReal.ts index f6c4153..613e3b9 100644 --- a/app/lib/makeReal.ts +++ b/app/lib/makeReal.ts @@ -31,8 +31,8 @@ export async function makeReal(editor: Editor, apiKey: string) { }) // Add the grid lines to the SVG - const grid = { color: 'red', size: 100, labels: true } - addGridToSvg(svg, grid) + // const grid = { color: 'red', size: 100, labels: true } + // addGridToSvg(svg, grid) if (!svg) throw Error(`Could not get the SVG.`) @@ -62,7 +62,7 @@ export async function makeReal(editor: Editor, apiKey: string) { apiKey, text: getSelectionAsText(editor), previousPreviews, - grid, + // grid, theme: editor.user.getUserPreferences().isDarkMode ? 'dark' : 'light', }) From 0938774630b0f6f67bc73000084ccf8bf60cbbd0 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Tue, 5 Mar 2024 11:52:26 +0000 Subject: [PATCH 3/3] Delete page.tsx --- app/page.tsx | 113 --------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 app/page.tsx diff --git a/app/page.tsx b/app/page.tsx deleted file mode 100644 index 4fe54fa..0000000 --- a/app/page.tsx +++ /dev/null @@ -1,113 +0,0 @@ -"use client"; - -import dynamic from "next/dynamic"; -import "tldraw/tldraw.css"; -import { useEditor } from "tldraw"; -import { getSvgAsImage } from "@/lib/getSvgAsImage"; -import { blobToBase64 } from "@/lib/blobToBase64"; -import React, { useEffect, useState } from "react"; -import ReactDOM from "react-dom"; -import { PreviewModal } from "@/components/PreviewModal"; - -const Tldraw = dynamic(async () => (await import("tldraw")).Tldraw, { - ssr: false, -}); - -export default function Home() { - const [html, setHtml] = useState(null); - - useEffect(() => { - const listener = (e: KeyboardEvent) => { - if (e.key === "Escape") { - setHtml(null); - } - }; - window.addEventListener("keydown", listener); - - return () => { - window.removeEventListener("keydown", listener); - }; - }); - - return ( - <> -
- - - -
- {html && - ReactDOM.createPortal( -
setHtml(null)} - > - -
, - document.body - )} - - ); -} - -function ExportButton({ setHtml }: { setHtml: (html: string) => void }) { - const editor = useEditor(); - const [loading, setLoading] = useState(false); - // A tailwind styled button that is pinned to the bottom right of the screen - return ( - - ); -}