| import { defaultHTML } from "@/lib/consts"; |
| import { HtmlHistory, Page } from "@/types"; |
| import { useState } from "react"; |
|
|
| export const useEditor = (initialPages?: Page[], initialPrompts?: string[], initialHtmlStorage?: string) => { |
| |
| |
| |
| |
| const [pages, setPages] = useState<Array<Page>>(initialPages ??[ |
| { |
| path: "index.html", |
| html: initialHtmlStorage ?? defaultHTML, |
| }, |
| ]); |
| |
| |
| |
| |
| const [htmlHistory, setHtmlHistory] = useState<HtmlHistory[]>([]); |
|
|
| |
| |
| |
| |
| const [prompts, setPrompts] = useState<string[]>( |
| initialPrompts ?? [] |
| ); |
|
|
|
|
| return { |
| htmlHistory, |
| setHtmlHistory, |
| prompts, |
| pages, |
| setPages, |
| setPrompts, |
| }; |
| }; |
|
|