File size: 833 Bytes
13ae717
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { HtmlHistory } from "@/types";
import { useState } from "react";

export const useEditor = (defaultHtml: string) => {
  /**
   * State to manage the HTML content of the editor.
   * This will be the main content that users edit.
   */
  const [html, setHtml] = useState(defaultHtml);
  /**
   * State to manage the history of HTML edits.
   * This will store previous versions of the HTML content along with metadata. (not saved to DB)
   */
  const [htmlHistory, setHtmlHistory] = useState<HtmlHistory[]>([]);

  /**
   * State to manage the prompts used for generating HTML content.
   * This can be used to track what prompts were used in the editor.
   */
  const [prompts, setPrompts] = useState<string[]>([]);

  return {
    html,
    setHtml,
    htmlHistory,
    setHtmlHistory,
    prompts,
    setPrompts,
  };
};