import React, { useContext, useState } from "react"; import { Empty, Row, Col, Button, Collapse, AutoComplete, TextArea, Popover, Toast, } from "@douyinfe/semi-ui"; import { IllustrationNoContent, IllustrationNoContentDark, } from "@douyinfe/semi-illustrations"; import { IconDeleteStroked, IconPlus, IconSearch, IconCheckboxTick, } from "@douyinfe/semi-icons"; import { NoteContext, UndoRedoContext } from "../pages/editor"; import { noteThemes, Action, ObjectType } from "../data/data"; export default function NotesOverview(props) { const { notes, setNotes, addNote, deleteNote } = useContext(NoteContext); const { setUndoStack, setRedoStack } = useContext(UndoRedoContext); const [value, setValue] = useState(""); const [editField, setEditField] = useState({}); const [activeKey, setActiveKey] = useState(""); const [filteredResult, setFilteredResult] = useState( notes.map((t) => { return t.title; }) ); const handleStringSearch = (value) => { setFilteredResult( notes .map((t) => { return t.title; }) .filter((i) => i.includes(value)) ); }; const updateNote = (id, values) => { setNotes((prev) => prev.map((note) => { if (note.id === id) { return { ...note, ...values }; } return note; }) ); }; return (
} placeholder="Search..." emptyContent={
No notes found
} onSearch={(v) => handleStringSearch(v)} onChange={(v) => setValue(v)} onSelect={(v) => { const { id } = notes.find((t) => t.title === v); setActiveKey(`${id}`); document .getElementById(`scroll_note_${id}`) .scrollIntoView({ behavior: "smooth" }); }} className="w-full" />
{notes.length <= 0 ? (
} darkModeImage={ } title="No text notes" description="Add notes cuz why not!" />
) : ( setActiveKey(k)} accordion > {notes.map((n, i) => ( {n.title}
} itemKey={`${n.id}`} id={`scroll_note_${n.id}`} key={n.id} >