wip target element + no follow up option
Browse filesFiles changed (14)
- app/api/ask-ai/route.ts+4-2
- components/editor/ask-ai/index.tsx+108-8
- components/editor/ask-ai/re-imagine.tsx+32-19
- components/editor/ask-ai/selected-html-element.tsxAdded+42
- components/editor/index.tsx+15
- components/editor/preview/index.tsx+99
- components/public/navigation/index.tsx+2-2
- components/space/ask-ai/index.tsx+32-27
- components/ui/checkbox.tsxAdded+32
- components/ui/collapsible.tsxAdded+33
- components/ui/switch.tsxAdded+31
- lib/html-tag-to-text.tsAdded+96
- package-lock.json+92
- package.json+3
222 unmodified lines22322422522622722822964 unmodified lines294295296297298299300222 unmodified linesconst userToken = request.cookies.get(MY_TOKEN_KEY())?.value;const body = await request.json();const { prompt, html, previousPrompt, provider } = body;if (!prompt || !html) {return NextResponse.json(64 unmodified lines},{role: "assistant",content: `The current code is: \n\`\`\`html\n${html}\n\`\`\``,},{role: "user",222 unmodified lines22322422522622722822964 unmodified lines294295296297298299300301302222 unmodified linesconst userToken = request.cookies.get(MY_TOKEN_KEY())?.value;const body = await request.json();const { prompt, html, previousPrompt, provider, selectedElementHtml } = body;if (!prompt || !html) {return NextResponse.json(64 unmodified lines},{role: "assistant",content: selectedElementHtml? `Here is the selected HTML element:\n\n${selectedElementHtml}`: `The current code is: \n\`\`\`html\n${html}\n\`\`\``,},{role: "user",
3 unmodified lines456789101 unmodified line12131415161718192021221 unmodified line2425262728295 unmodified lines35363738394011 unmodified lines5253545556578 unmodified lines666768697071727374757677782 unmodified lines818283848586176 unmodified lines26326426526626726832 unmodified lines30130230330430530615 unmodified lines3223233243253263273283293307 unmodified lines3383393403413423433443 unmodified linesimport classNames from "classnames";import { toast } from "sonner";import { useLocalStorage, useUpdateEffect } from "react-use";import { ArrowUp, ChevronDown } from "lucide-react";import { FaStopCircle } from "react-icons/fa";import { defaultHTML } from "@/lib/consts";1 unmodified lineimport { Button } from "@/components/ui/button";import { MODELS } from "@/lib/providers";import { HtmlHistory } from "@/types";import { InviteFriends } from "@/components/invite-friends";import { Settings } from "@/components/editor/ask-ai/settings";import { LoginModal } from "@/components/login-modal";import { ReImagine } from "@/components/editor/ask-ai/re-imagine";import Loading from "@/components/loading";export function AskAI({html,1 unmodified lineonScrollToBottom,isAiWorking,setisAiWorking,onNewPrompt,onSuccess,}: {5 unmodified lineshtmlHistory?: HtmlHistory[];setisAiWorking: React.Dispatch<React.SetStateAction<boolean>>;onSuccess: (h: string, p: string, n?: number[][]) => void;}) {const refThink = useRef<HTMLDivElement | null>(null);const audio = useRef<HTMLAudioElement | null>(null);11 unmodified linesconst [openThink, setOpenThink] = useState(false);const [isThinking, setIsThinking] = useState(true);const [controller, setController] = useState<AbortController | null>(null);const callAi = async (redesignMarkdown?: string) => {if (isAiWorking) return;8 unmodified lineslet thinkResponse = "";let lastRenderTime = 0;const isFollowUp = html !== defaultHTML;const abortController = new AbortController();setController(abortController);try {onNewPrompt(prompt);if (isFollowUp && !redesignMarkdown) {// TODO use @/lib/api instead of fetch directly (if possible)const request = await fetch("/api/ask-ai", {method: "PUT",body: JSON.stringify({2 unmodified linespreviousPrompt,model,html,}),headers: {"Content-Type": "application/json",176 unmodified linesreturn (<><div className="bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent z-10 w-full group">{think && (<div className="w-full border-b border-neutral-700 relative overflow-hidden">32 unmodified lines</main></div>)}<div className="w-full relative flex items-center justify-between">{isAiWorking && (<div className="absolute bg-neutral-800 rounded-lg bottom-0 left-4 w-[calc(100%-30px)] h-full z-1 flex items-center justify-between max-lg:text-sm">15 unmodified lines<inputtype="text"disabled={isAiWorking}className="w-full bg-transparent text-sm outline-none text-white placeholder:text-neutral-400 p-4"placeholder={hasAsked ? "Ask DeepSite for edits" : "Ask DeepSite anything..."}value={prompt}onChange={(e) => setPrompt(e.target.value)}7 unmodified lines<div className="flex items-center justify-between gap-2 px-4 pb-3"><div className="flex-1 flex items-center justify-start gap-1.5"><ReImagine onRedesign={(md) => callAi(md)} /><InviteFriends /></div><div className="flex items-center justify-end gap-2"><Settings3 unmodified lines456789101 unmodified line12131415161718192021222324252627282930311 unmodified line333435363738394041425 unmodified lines4849505152535455565711 unmodified lines697071727374758 unmodified lines84858687888990919293949596972 unmodified lines100101102103104105106176 unmodified lines28328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532 unmodified lines35835936036136236336436536636736836937037115 unmodified lines3873883893903913923933943953963973983994004014024034047 unmodified lines4124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434443 unmodified linesimport classNames from "classnames";import { toast } from "sonner";import { useLocalStorage, useUpdateEffect } from "react-use";import { ArrowUp, ChevronDown, Info, Crosshair } from "lucide-react";import { FaStopCircle } from "react-icons/fa";import { defaultHTML } from "@/lib/consts";1 unmodified lineimport { Button } from "@/components/ui/button";import { MODELS } from "@/lib/providers";import { HtmlHistory } from "@/types";// import { InviteFriends } from "@/components/invite-friends";import { Settings } from "@/components/editor/ask-ai/settings";import { LoginModal } from "@/components/login-modal";import { ReImagine } from "@/components/editor/ask-ai/re-imagine";import Loading from "@/components/loading";import {Popover,PopoverContent,PopoverTrigger,} from "@/components/ui/popover";import { Checkbox } from "@/components/ui/checkbox";import { Tooltip, TooltipTrigger } from "@/components/ui/tooltip";import { TooltipContent } from "@radix-ui/react-tooltip";import { SelectedHtmlElement } from "./selected-html-element";export function AskAI({html,1 unmodified lineonScrollToBottom,isAiWorking,setisAiWorking,isEditableModeEnabled = false,selectedElement,setSelectedElement,setIsEditableModeEnabled,onNewPrompt,onSuccess,}: {5 unmodified lineshtmlHistory?: HtmlHistory[];setisAiWorking: React.Dispatch<React.SetStateAction<boolean>>;onSuccess: (h: string, p: string, n?: number[][]) => void;isEditableModeEnabled: boolean;setIsEditableModeEnabled: React.Dispatch<React.SetStateAction<boolean>>;selectedElement?: HTMLElement | null;setSelectedElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;}) {const refThink = useRef<HTMLDivElement | null>(null);const audio = useRef<HTMLAudioElement | null>(null);11 unmodified linesconst [openThink, setOpenThink] = useState(false);const [isThinking, setIsThinking] = useState(true);const [controller, setController] = useState<AbortController | null>(null);const [isFollowUp, setIsFollowUp] = useState(true);const callAi = async (redesignMarkdown?: string) => {if (isAiWorking) return;8 unmodified lineslet thinkResponse = "";let lastRenderTime = 0;const abortController = new AbortController();setController(abortController);try {onNewPrompt(prompt);if (isFollowUp && !redesignMarkdown && html !== defaultHTML) {const selectedElementHtml = selectedElement? selectedElement.outerHTML: "";const request = await fetch("/api/ask-ai", {method: "PUT",body: JSON.stringify({2 unmodified linespreviousPrompt,model,html,selectedElementHtml,}),headers: {"Content-Type": "application/json",176 unmodified linesreturn (<><div className="ml-auto select-none text-xs text-neutral-400 flex items-center justify-center gap-2 bg-neutral-800 border border-neutral-700 rounded-md p-1 pr-2.5 max-w-max"><labelhtmlFor="follow-up-checkbox"className="flex items-center gap-1.5 cursor-pointer"><Checkboxid="follow-up-checkbox"checked={isFollowUp}onCheckedChange={(e) => {setIsFollowUp(e === true);}}/>Follow-Up</label><Popover><PopoverTrigger asChild><Info className="size-3 text-neutral-300 cursor-pointer" /></PopoverTrigger><PopoverContentalign="start"className="!rounded-2xl !p-0 min-w-xs text-center overflow-hidden"><header className="bg-neutral-950 px-4 py-3 border-b border-neutral-700/70"><p className="text-base text-neutral-200 font-semibold">What is a Follow-Up?</p></header><main className="p-4"><p className="text-sm text-neutral-400">A Follow-Up is a request to DeepSite to edit the current HTMLinstead of starting from scratch. This is useful when you wantto make small changes or improvements to the existing design.</p></main></PopoverContent></Popover></div><div className="bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent z-10 w-full group">{think && (<div className="w-full border-b border-neutral-700 relative overflow-hidden">32 unmodified lines</main></div>)}{!isAiWorking && selectedElement && (<div className="px-4 pt-3"><SelectedHtmlElementelement={selectedElement}onDelete={() => setSelectedElement(null)}/></div>)}<div className="w-full relative flex items-center justify-between">{isAiWorking && (<div className="absolute bg-neutral-800 rounded-lg bottom-0 left-4 w-[calc(100%-30px)] h-full z-1 flex items-center justify-between max-lg:text-sm">15 unmodified lines<inputtype="text"disabled={isAiWorking}className={classNames("w-full bg-transparent text-sm outline-none text-white placeholder:text-neutral-400 p-4",{"!pt-2.5": selectedElement && !isAiWorking,})}placeholder={selectedElement? `Ask DeepSite about ${selectedElement.tagName.toLowerCase()}...`: hasAsked? "Ask DeepSite for edits": "Ask DeepSite anything..."}value={prompt}onChange={(e) => setPrompt(e.target.value)}7 unmodified lines<div className="flex items-center justify-between gap-2 px-4 pb-3"><div className="flex-1 flex items-center justify-start gap-1.5"><ReImagine onRedesign={(md) => callAi(md)} />{html !== defaultHTML && (<Tooltip><TooltipTrigger asChild><Buttonsize="xs"variant={isEditableModeEnabled ? "default" : "outline"}onClick={() => {setIsEditableModeEnabled?.(!isEditableModeEnabled);}}className={classNames("h-[28px]", {"!text-neutral-400 hover:!text-neutral-200 !border-neutral-600 !hover:!border-neutral-500":!isEditableModeEnabled,})}><Crosshair className="size-4" />Edit</Button></TooltipTrigger><TooltipContentalign="start"className="bg-neutral-950 text-xs text-neutral-200 py-1 px-2 rounded-md -translate-y-0.5">Select an element on the page to ask DeepSite edit itdirectly.</TooltipContent></Tooltip>)}</div><div className="flex items-center justify-end gap-2"><Settings
9 unmodified lines10111213141513 unmodified lines2930313233342 unmodified lines37383940414243444546474849505152535455565758596065 unmodified lines1261271281291301311321331341359 unmodified lines} from "@/components/ui/popover";import { Input } from "@/components/ui/input";import Loading from "@/components/loading";export function ReImagine({onRedesign,13 unmodified lines};const handleClick = async () => {if (!url) {toast.error("Please enter a URL.");return;2 unmodified linestoast.error("Please enter a valid URL.");return;}// Here you would typically handle the re-design logicsetIsLoading(true);const request = await fetch("/api/re-design", {method: "POST",body: JSON.stringify({ url }),headers: {"Content-Type": "application/json",},});const response = await request.json();if (response.ok) {setOpen(false);setUrl("");onRedesign(response.markdown);toast.success("DeepSite is redesigning your site! Let him cook... 🔥");} else {toast.error(response.message || "Failed to redesign the site.");}setIsLoading(false);};65 unmodified linesvariant="black"onClick={handleClick}className="relative w-full"disabled={isLoading}>Redesign <Paintbrush className="size-4" />{isLoading && <Loading className="ml-2 size-4 animate-spin" />}</Button></div></main>9 unmodified lines1011121314151613 unmodified lines303132333435362 unmodified lines3940414243444546474849505152535455565758596061626365 unmodified lines1291301311321331341351361371381391401411421431441451461471489 unmodified lines} from "@/components/ui/popover";import { Input } from "@/components/ui/input";import Loading from "@/components/loading";import { api } from "@/lib/api";export function ReImagine({onRedesign,13 unmodified lines};const handleClick = async () => {if (isLoading) return; // Prevent multiple clicks while loadingif (!url) {toast.error("Please enter a URL.");return;2 unmodified linestoast.error("Please enter a valid URL.");return;}// TODO implement the API call to redesign the site// Here you would typically handle the re-design logicsetIsLoading(true);// const request = await api.post("/api/re-design", {// method: "POST",// body: JSON.stringify({ url }),// headers: {// "Content-Type": "application/json",// },// });// const response = await request.json();// if (response.ok) {// setOpen(false);// setUrl("");// onRedesign(response.markdown);// toast.success("DeepSite is redesigning your site! Let him cook... 🔥");// } else {// toast.error(response.message || "Failed to redesign the site.");// }setIsLoading(false);};65 unmodified linesvariant="black"onClick={handleClick}className="relative w-full">{isLoading ? (<><Loadingoverlay={false}className="ml-2 size-4 animate-spin"/>Fetching your site...</>) : (<>Redesign <Paintbrush className="size-4" /></>)}</Button></div></main>
123456789101112131415161718192021222324252627282930313233343536373839404142import { Collapsible, CollapsibleTrigger } from "@/components/ui/collapsible";import { htmlTagToText } from "@/lib/html-tag-to-text";import { Code, XCircle } from "lucide-react";
export const SelectedHtmlElement = ({ element, onDelete,}: { element: HTMLElement | null; onDelete?: () => void;}) => { if (!element) return null;
const tagName = element.tagName.toLowerCase(); return ( <Collapsible className="border border-neutral-700 rounded-xl p-1.5 pr-3 max-w-max hover:brightness-110 transition-all duration-200 ease-in-out !cursor-pointer" onClick={onDelete} > <CollapsibleTrigger className="flex items-center justify-start gap-2 cursor-pointer"> <div className="rounded-lg bg-neutral-700 size-6 flex items-center justify-center"> <Code className="text-neutral-300 size-3.5" /> </div> <p className="text-sm font-semibold text-neutral-300"> {htmlTagToText(tagName)} </p> <XCircle className="text-neutral-300 size-4" /> </CollapsibleTrigger> {/* <CollapsibleContent className="border-t border-neutral-700 pt-2 mt-2"> <div className="text-xs text-neutral-400"> <p> <span className="font-semibold">ID:</span> {element.id || "No ID"} </p> <p> <span className="font-semibold">Classes:</span>{" "} {element.className || "No classes"} </p> </div> </CollapsibleContent> */} </Collapsible> );};46 unmodified lines474849505152105 unmodified lines15815916016116216370 unmodified lines23423523623723823929 unmodified lines2692702712722732749 unmodified lines28428528628728828929046 unmodified linesconst [device, setDevice] = useState<"desktop" | "mobile">("desktop");const [isResizing, setIsResizing] = useState(false);const [isAiWorking, setIsAiWorking] = useState(false);/*** Resets the layout based on screen size105 unmodified linesresizer.current.addEventListener("mousedown", handleMouseDown);}} else {if (preview.current) {// Reset preview width when switching to preview tabpreview.current.style.width = "100%";70 unmodified linesprompt: p,});setHtmlHistory(currentHistory);// if xs or smif (window.innerWidth <= 1024) {setCurrentTab("preview");29 unmodified lineseditorRef.current?.getModel()?.getLineCount() ?? 0);}}/></div><div9 unmodified linesref={preview}device={device}currentTab={currentTab}iframeRef={iframeRef}/></main><Footer46 unmodified lines47484950515253545556105 unmodified lines16216316416516616716870 unmodified lines23924024124224324424529 unmodified lines2752762772782792802812822832849 unmodified lines29429529629729829930030130230330430546 unmodified linesconst [device, setDevice] = useState<"desktop" | "mobile">("desktop");const [isResizing, setIsResizing] = useState(false);const [isAiWorking, setIsAiWorking] = useState(false);const [isEditableModeEnabled, setIsEditableModeEnabled] = useState(false);const [selectedElement, setSelectedElement] = useState<HTMLElement | null>(null);/*** Resets the layout based on screen size105 unmodified linesresizer.current.addEventListener("mousedown", handleMouseDown);}} else {setIsEditableModeEnabled(false);if (preview.current) {// Reset preview width when switching to preview tabpreview.current.style.width = "100%";70 unmodified linesprompt: p,});setHtmlHistory(currentHistory);setSelectedElement(null);// if xs or smif (window.innerWidth <= 1024) {setCurrentTab("preview");29 unmodified lineseditorRef.current?.getModel()?.getLineCount() ?? 0);}}isEditableModeEnabled={isEditableModeEnabled}setIsEditableModeEnabled={setIsEditableModeEnabled}selectedElement={selectedElement}setSelectedElement={setSelectedElement}/></div><div9 unmodified linesref={preview}device={device}currentTab={currentTab}isEditableModeEnabled={isEditableModeEnabled}iframeRef={iframeRef}onClickElement={(element) => {setIsEditableModeEnabled(false);setSelectedElement(element);}}/></main><Footer
1234567893 unmodified lines1314151617182 unmodified lines2122232425262721 unmodified lines495051525354"use client";import classNames from "classnames";import { toast } from "sonner";import { cn } from "@/lib/utils";import { GridPattern } from "@/components/magic-ui/grid-pattern";export const Preview = ({html,3 unmodified linesdevice,currentTab,iframeRef,}: {html: string;isResizing: boolean;2 unmodified linesiframeRef?: React.RefObject<HTMLIFrameElement | null>;device: "desktop" | "mobile";currentTab: string;}) => {return (<divref={ref}21 unmodified lines"[mask-image:radial-gradient(900px_circle_at_center,white,transparent)]")}/><iframeid="preview-iframe"ref={iframeRef}1234567891011123 unmodified lines16171819202122232 unmodified lines262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410521 unmodified lines127128129130131132133134135136137138139140141142143144145146147148149150151152153"use client";import { useUpdateEffect } from "react-use";import { useMemo, useState } from "react";import classNames from "classnames";import { toast } from "sonner";import { cn } from "@/lib/utils";import { GridPattern } from "@/components/magic-ui/grid-pattern";import { htmlTagToText } from "@/lib/html-tag-to-text";export const Preview = ({html,3 unmodified linesdevice,currentTab,iframeRef,isEditableModeEnabled,onClickElement,}: {html: string;isResizing: boolean;2 unmodified linesiframeRef?: React.RefObject<HTMLIFrameElement | null>;device: "desktop" | "mobile";currentTab: string;isEditableModeEnabled?: boolean;onClickElement?: (element: HTMLElement) => void;}) => {const [hoveredElement, setHoveredElement] = useState<HTMLElement | null>(null);// add event listener to the iframe to track hovered elementsconst handleMouseOver = (event: MouseEvent) => {if (iframeRef?.current) {const iframeDocument = iframeRef.current.contentDocument;if (iframeDocument) {const targetElement = event.target as HTMLElement;if (hoveredElement !== targetElement &&targetElement !== iframeDocument.body) {setHoveredElement(targetElement);targetElement.classList.add("hovered-element");} else {return setHoveredElement(null);}}}};const handleMouseOut = () => {setHoveredElement(null);};const handleClick = (event: MouseEvent) => {if (iframeRef?.current) {const iframeDocument = iframeRef.current.contentDocument;if (iframeDocument) {const targetElement = event.target as HTMLElement;if (targetElement !== iframeDocument.body) {onClickElement?.(targetElement);}}}};useUpdateEffect(() => {const cleanupListeners = () => {if (iframeRef?.current?.contentDocument) {const iframeDocument = iframeRef.current.contentDocument;iframeDocument.removeEventListener("mouseover", handleMouseOver);iframeDocument.removeEventListener("mouseout", handleMouseOut);iframeDocument.removeEventListener("click", handleClick);}};if (iframeRef?.current) {const iframeDocument = iframeRef.current.contentDocument;if (iframeDocument) {// Clean up existing listeners firstcleanupListeners();if (isEditableModeEnabled) {iframeDocument.addEventListener("mouseover", handleMouseOver);iframeDocument.addEventListener("mouseout", handleMouseOut);iframeDocument.addEventListener("click", handleClick);}}}// Clean up when component unmounts or dependencies changereturn cleanupListeners;}, [iframeRef, isEditableModeEnabled]);const selectedElement = useMemo(() => {if (!isEditableModeEnabled) return null;if (!hoveredElement) return null;return hoveredElement;}, [hoveredElement, isEditableModeEnabled]);return (<divref={ref}21 unmodified lines"[mask-image:radial-gradient(900px_circle_at_center,white,transparent)]")}/>{!isAiWorking && hoveredElement && selectedElement && (<divclassName="cursor-pointer absolute bg-sky-500/10 border-[2px] border-dashed border-sky-500 rounded-r-lg rounded-b-lg p-3 z-10 pointer-events-none"style={{top:selectedElement.getBoundingClientRect().top +(iframeRef?.current?.contentWindow?.scrollY || 0) +24,left:selectedElement.getBoundingClientRect().left +(iframeRef?.current?.contentWindow?.scrollX || 0) +24,width: selectedElement.getBoundingClientRect().width,height: selectedElement.getBoundingClientRect().height,}}><span className="bg-sky-500 rounded-t-md text-sm text-neutral-100 px-2 py-0.5 -translate-y-7 absolute top-0 left-0">{htmlTagToText(selectedElement.tagName.toLowerCase())}</span></div>)}<iframeid="preview-iframe"ref={iframeRef}
84 unmodified lines858687888990914 unmodified lines9697989910010110284 unmodified lines})}><nav className="grid grid-cols-3 p-4 container mx-auto"><Link href="/" className="flex items-center gap-1"><Imagesrc={Logo}4 unmodified lines/><p className="font-sans text-white text-xl font-bold">DeepSite</p></Link><ul className="flex items-center justify-center gap-6">{navigationLinks.map((link) => (<likey={link.name}84 unmodified lines858687888990914 unmodified lines9697989910010110284 unmodified lines})}><nav className="grid grid-cols-2 p-4 container mx-auto"><Link href="/" className="flex items-center gap-1"><Imagesrc={Logo}4 unmodified lines/><p className="font-sans text-white text-xl font-bold">DeepSite</p></Link><ul className="items-center justify-center gap-6 hidden">{navigationLinks.map((link) => (<likey={link.name}
7 unmodified lines8910111213141516171819202122232425262728293031323334353637383940417 unmodified linesexport const AskAi = () => {return (<div className="bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent group"><textarearows={3}className="w-full bg-transparent text-sm outline-none text-white placeholder:text-neutral-400 p-4 resize-none mb-1"placeholder="Ask DeepSite anything..."onChange={() => {}}onKeyDown={() => {}}/><div className="flex items-center justify-between gap-2 px-4 pb-3"><div className="flex-1 flex justify-start"><Buttonsize="iconXs"variant="outline"className="!border-neutral-600 !text-neutral-400 !hover:!border-neutral-500 hover:!text-neutral-300"><TiUserAdd className="size-4" /></Button></div><div className="flex items-center justify-end gap-2"><Button variant="black" size="sm"><PiGearSixFill className="size-4" />Settings</Button><Button size="iconXs"><ArrowUp className="size-4" /></Button></div></div></div>);};7 unmodified lines89101112131415161718192021222324252627282930313233343536373839404142434445467 unmodified linesexport const AskAi = () => {return (<><div className="bg-red-500 flex items-center justify-end">No Follow-up mode</div><div className="bg-neutral-800 border border-neutral-700 rounded-2xl ring-[4px] focus-within:ring-neutral-500/30 focus-within:border-neutral-600 ring-transparent group"><textarearows={3}className="w-full bg-transparent text-sm outline-none text-white placeholder:text-neutral-400 p-4 resize-none mb-1"placeholder="Ask DeepSite anything..."onChange={() => {}}onKeyDown={() => {}}/><div className="flex items-center justify-between gap-2 px-4 pb-3"><div className="flex-1 flex justify-start"><Buttonsize="iconXs"variant="outline"className="!border-neutral-600 !text-neutral-400 !hover:!border-neutral-500 hover:!text-neutral-300"><TiUserAdd className="size-4" /></Button></div><div className="flex items-center justify-end gap-2"><Button variant="black" size="sm"><PiGearSixFill className="size-4" />Settings</Button><Button size="iconXs"><ArrowUp className="size-4" /></Button></div></div></div></>);};
1234567891011121314151617181920212223242526272829303132"use client";
import * as React from "react";import * as CheckboxPrimitive from "@radix-ui/react-checkbox";import { CheckIcon } from "lucide-react";
import { cn } from "@/lib/utils";
function Checkbox({ className, ...props}: React.ComponentProps<typeof CheckboxPrimitive.Root>) { return ( <CheckboxPrimitive.Root data-slot="checkbox" className={cn( "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-3.5 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className )} {...props} > <CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="flex items-center justify-center text-current transition-none" > <CheckIcon className="size-3" /> </CheckboxPrimitive.Indicator> </CheckboxPrimitive.Root> );}
export { Checkbox };123456789101112131415161718192021222324252627282930313233"use client"
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
function Collapsible({ ...props}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) { return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />}
function CollapsibleTrigger({ ...props}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) { return ( <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} /> )}
function CollapsibleContent({ ...props}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) { return ( <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} /> )}
export { Collapsible, CollapsibleTrigger, CollapsibleContent }12345678910111213141516171819202122232425262728293031"use client"
import * as React from "react"import * as SwitchPrimitive from "@radix-ui/react-switch"
import { cn } from "@/lib/utils"
function Switch({ className, ...props}: React.ComponentProps<typeof SwitchPrimitive.Root>) { return ( <SwitchPrimitive.Root data-slot="switch" className={cn( "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className )} {...props} > <SwitchPrimitive.Thumb data-slot="switch-thumb" className={cn( "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0" )} /> </SwitchPrimitive.Root> )}
export { Switch }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596export const htmlTagToText = (tagName: string): string => { switch (tagName.toLowerCase()) { case "h1": return "Heading 1"; case "h2": return "Heading 2"; case "h3": return "Heading 3"; case "h4": return "Heading 4"; case "h5": return "Heading 5"; case "h6": return "Heading 6"; case "p": return "Text Paragraph"; case "span": return "Inline Text"; case "button": return "Button"; case "input": return "Input Field"; case "select": return "Select Dropdown"; case "textarea": return "Text Area"; case "form": return "Form"; case "table": return "Table"; case "thead": return "Table Header"; case "tbody": return "Table Body"; case "tr": return "Table Row"; case "th": return "Table Header Cell"; case "td": return "Table Data Cell"; case "nav": return "Navigation"; case "header": return "Header"; case "footer": return "Footer"; case "section": return "Section"; case "article": return "Article"; case "aside": return "Aside"; case "div": return "Division"; case "main": return "Main Content"; case "details": return "Details"; case "summary": return "Summary"; case "code": return "Code Snippet"; case "pre": return "Preformatted Text"; case "kbd": return "Keyboard Input"; case "label": return "Label"; case "canvas": return "Canvas"; case "svg": return "SVG Graphic"; case "video": return "Video Player"; case "audio": return "Audio Player"; case "iframe": return "Embedded Frame"; case "link": return "Link"; case "a": return "Link"; case "img": return "Image"; case "ul": return "Unordered List"; case "ol": return "Ordered List"; case "li": return "List Item"; case "blockquote": return "Blockquote"; default: return tagName.charAt(0).toUpperCase() + tagName.slice(1); }};11 unmodified lines12131415161718192021221146 unmodified lines116911701171117211731174487 unmodified lines16621663166416651666166711 unmodified lines"@huggingface/inference": "^4.0.3","@monaco-editor/react": "^4.7.0","@radix-ui/react-avatar": "^1.1.10","@radix-ui/react-dialog": "^1.1.14","@radix-ui/react-dropdown-menu": "^2.1.15","@radix-ui/react-popover": "^1.1.14","@radix-ui/react-select": "^2.2.5","@radix-ui/react-slot": "^1.2.3","@radix-ui/react-tabs": "^1.1.12","@radix-ui/react-toggle": "^1.1.9","@radix-ui/react-toggle-group": "^1.1.10",1146 unmodified lines}}},"node_modules/@radix-ui/react-collection": {"version": "1.1.7","resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",487 unmodified lines}}},"node_modules/@radix-ui/react-tabs": {"version": "1.1.12","resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.12.tgz",11 unmodified lines12131415161718192021222324251146 unmodified lines117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237487 unmodified lines1725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175911 unmodified lines"@huggingface/inference": "^4.0.3","@monaco-editor/react": "^4.7.0","@radix-ui/react-avatar": "^1.1.10","@radix-ui/react-checkbox": "^1.3.2","@radix-ui/react-collapsible": "^1.1.11","@radix-ui/react-dialog": "^1.1.14","@radix-ui/react-dropdown-menu": "^2.1.15","@radix-ui/react-popover": "^1.1.14","@radix-ui/react-select": "^2.2.5","@radix-ui/react-slot": "^1.2.3","@radix-ui/react-switch": "^1.2.5","@radix-ui/react-tabs": "^1.1.12","@radix-ui/react-toggle": "^1.1.9","@radix-ui/react-toggle-group": "^1.1.10",1146 unmodified lines}}},"node_modules/@radix-ui/react-checkbox": {"version": "1.3.2","resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.2.tgz","integrity": "sha512-yd+dI56KZqawxKZrJ31eENUwqc1QSqg4OZ15rybGjF2ZNwMO+wCyHzAVLRp9qoYJf7kYy0YpZ2b0JCzJ42HZpA==","license": "MIT","dependencies": {"@radix-ui/primitive": "1.1.2","@radix-ui/react-compose-refs": "1.1.2","@radix-ui/react-context": "1.1.2","@radix-ui/react-presence": "1.1.4","@radix-ui/react-primitive": "2.1.3","@radix-ui/react-use-controllable-state": "1.2.2","@radix-ui/react-use-previous": "1.1.1","@radix-ui/react-use-size": "1.1.1"},"peerDependencies": {"@types/react": "*","@types/react-dom": "*","react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc","react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"},"peerDependenciesMeta": {"@types/react": {"optional": true},"@types/react-dom": {"optional": true}}},"node_modules/@radix-ui/react-collapsible": {"version": "1.1.11","resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.11.tgz","integrity": "sha512-2qrRsVGSCYasSz1RFOorXwl0H7g7J1frQtgpQgYrt+MOidtPAINHn9CPovQXb83r8ahapdx3Tu0fa/pdFFSdPg==","license": "MIT","dependencies": {"@radix-ui/primitive": "1.1.2","@radix-ui/react-compose-refs": "1.1.2","@radix-ui/react-context": "1.1.2","@radix-ui/react-id": "1.1.1","@radix-ui/react-presence": "1.1.4","@radix-ui/react-primitive": "2.1.3","@radix-ui/react-use-controllable-state": "1.2.2","@radix-ui/react-use-layout-effect": "1.1.1"},"peerDependencies": {"@types/react": "*","@types/react-dom": "*","react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc","react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"},"peerDependenciesMeta": {"@types/react": {"optional": true},"@types/react-dom": {"optional": true}}},"node_modules/@radix-ui/react-collection": {"version": "1.1.7","resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",487 unmodified lines}}},"node_modules/@radix-ui/react-switch": {"version": "1.2.5","resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.2.5.tgz","integrity": "sha512-5ijLkak6ZMylXsaImpZ8u4Rlf5grRmoc0p0QeX9VJtlrM4f5m3nCTX8tWga/zOA8PZYIR/t0p2Mnvd7InrJ6yQ==","license": "MIT","dependencies": {"@radix-ui/primitive": "1.1.2","@radix-ui/react-compose-refs": "1.1.2","@radix-ui/react-context": "1.1.2","@radix-ui/react-primitive": "2.1.3","@radix-ui/react-use-controllable-state": "1.2.2","@radix-ui/react-use-previous": "1.1.1","@radix-ui/react-use-size": "1.1.1"},"peerDependencies": {"@types/react": "*","@types/react-dom": "*","react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc","react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"},"peerDependenciesMeta": {"@types/react": {"optional": true},"@types/react-dom": {"optional": true}}},"node_modules/@radix-ui/react-tabs": {"version": "1.1.12","resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.12.tgz",
12 unmodified lines131415161718192021222312 unmodified lines"@huggingface/inference": "^4.0.3","@monaco-editor/react": "^4.7.0","@radix-ui/react-avatar": "^1.1.10","@radix-ui/react-dialog": "^1.1.14","@radix-ui/react-dropdown-menu": "^2.1.15","@radix-ui/react-popover": "^1.1.14","@radix-ui/react-select": "^2.2.5","@radix-ui/react-slot": "^1.2.3","@radix-ui/react-tabs": "^1.1.12","@radix-ui/react-toggle": "^1.1.9","@radix-ui/react-toggle-group": "^1.1.10",12 unmodified lines131415161718192021222324252612 unmodified lines"@huggingface/inference": "^4.0.3","@monaco-editor/react": "^4.7.0","@radix-ui/react-avatar": "^1.1.10","@radix-ui/react-checkbox": "^1.3.2","@radix-ui/react-collapsible": "^1.1.11","@radix-ui/react-dialog": "^1.1.14","@radix-ui/react-dropdown-menu": "^2.1.15","@radix-ui/react-popover": "^1.1.14","@radix-ui/react-select": "^2.2.5","@radix-ui/react-slot": "^1.2.3","@radix-ui/react-switch": "^1.2.5","@radix-ui/react-tabs": "^1.1.12","@radix-ui/react-toggle": "^1.1.9","@radix-ui/react-toggle-group": "^1.1.10",
app/api/ask-ai/route.ts+4-2
components/editor/ask-ai/index.tsx+108-8
components/editor/ask-ai/re-imagine.tsx+32-19
components/editor/ask-ai/selected-html-element.tsxAdded+42
components/editor/index.tsx+15
components/editor/preview/index.tsx+99
components/public/navigation/index.tsx+2-2
components/space/ask-ai/index.tsx+32-27
components/ui/checkbox.tsxAdded+32
components/ui/collapsible.tsxAdded+33
components/ui/switch.tsxAdded+31
lib/html-tag-to-text.tsAdded+96
package-lock.json+92
package.json+3