import { Editor } from "novel"; import { DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../ui/dialog"; import { Input } from "../ui/input"; import { Label } from "../ui/label"; import { Markdown } from "tiptap-markdown"; import { useEffect, useRef, useState } from "react"; import { FilterSpaces } from "./FilterCombobox"; import { useMemory } from "@/contexts/MemoryContext"; export function AddMemoryPage() { const { addMemory } = useMemory(); const [url, setUrl] = useState(""); const [selectedSpacesId, setSelectedSpacesId] = useState([]); return (
Add a web page to memory This will take you the web page you are trying to add to memory, where the extension will save the page to memory setUrl(e.target.value)} /> Cancel
); } export function NoteAddPage({ closeDialog }: { closeDialog: () => void }) { const [selectedSpacesId, setSelectedSpacesId] = useState([]); const inputRef = useRef(null); const [name, setName] = useState(""); const [content, setContent] = useState(""); const [loading, setLoading] = useState(false); function check(): boolean { const data = { name: name.trim(), content, }; if (!data.name || data.name.length < 1) { if (!inputRef.current) { alert("Please enter a name for the note"); return false; } inputRef.current.value = ""; inputRef.current.placeholder = "Please enter a title for the note"; inputRef.current.dataset["error"] = "true"; setTimeout(() => { inputRef.current!.placeholder = "Title of the note"; inputRef.current!.dataset["error"] = "false"; }, 500); inputRef.current.focus(); return false; } return true; } return (
setName(e.target.value)} /> { if (!editor) return; setContent(editor.storage.markdown.getMarkdown()); }} extensions={[Markdown]} className="novel-editor bg-rgray-4 border-rgray-7 dark mt-5 max-h-[60vh] min-h-[40vh] w-[50vw] overflow-y-auto rounded-lg border [&>div>div]:p-5" /> Cancel
); } export function SpaceAddPage({ closeDialog }: { closeDialog: () => void }) { const [selectedSpacesId, setSelectedSpacesId] = useState([]); const inputRef = useRef(null); const [name, setName] = useState(""); const [content, setContent] = useState(""); const [loading, setLoading] = useState(false); function check(): boolean { const data = { name: name.trim(), content, }; console.log(name); if (!data.name || data.name.length < 1) { if (!inputRef.current) { alert("Please enter a name for the note"); return false; } inputRef.current.value = ""; inputRef.current.placeholder = "Please enter a title for the note"; inputRef.current.dataset["error"] = "true"; setTimeout(() => { inputRef.current!.placeholder = "Title of the note"; inputRef.current!.dataset["error"] = "false"; }, 500); inputRef.current.focus(); return false; } return true; } return (
Add a space Add Cancel
); }