// Everything you have marked in the Bible: highlights (grouped and filtered by colour, each colour // named by you — "Promises", "Commands") and bookmarks. Opens from the bookmark button in the top bar. import { useEffect, useState } from 'react'; import Sheet from './Sheet.jsx'; import { CloseIcon } from './icons.jsx'; import MarkNote from './MarkNote.jsx'; import { buildMarksDocxBlob, buildMarksModel, downloadMarksFile, marksToMarkdown } from '../../utils/marksExport.js'; import { COLOR_NAMES, COLOR_SUGGESTIONS, HIGHLIGHT_COLORS, colorTitle } from '../../utils/highlightColors.js'; const tabBtn = (active) => `rounded-full border px-3 py-1 text-xs font-medium ${active ? 'border-[var(--r-text)] bg-[var(--r-text)] text-[var(--r-bg)]' : 'border-[var(--r-line)] text-[var(--r-sub)] hover:bg-black/5'}`; export default function MarksSheet({ open, onClose, initialTab = 'highlights', bookmarks, highlights, colorLabels, onSetLabel, onJump, onRemoveBookmark, onRemoveHighlight, bookmarkNotes = {}, onSetHighlightNote, onSetBookmarkNote, }) { const [tab, setTab] = useState(initialTab); // Opening from the Highlights button shows highlights; from the Bookmarks button, bookmarks useEffect(() => { if (open) setTab(initialTab); }, [open, initialTab]); const [filter, setFilter] = useState(null); // a highlight colour, or null for all const [editing, setEditing] = useState(false); const counts = Object.fromEntries(HIGHLIGHT_COLORS.map((c) => [c, highlights.filter((h) => h.color === c).length])); const shown = filter ? highlights.filter((h) => h.color === filter) : highlights; // Colours in use that aren't one of the picker's (older data) still get listed const total = highlights.length + bookmarks.length; const [exportError, setExportError] = useState(''); const exportAs = async (kind) => { setExportError(''); const model = buildMarksModel({ highlights, bookmarks, colorLabels, bookmarkNotes }); try { if (kind === 'md') downloadMarksFile(new Blob([marksToMarkdown(model)], { type: 'text/markdown;charset=utf-8' }), 'highlights-and-bookmarks.md'); else downloadMarksFile(await buildMarksDocxBlob(model), 'highlights-and-bookmarks.docx'); } catch { setExportError('Couldn’t make the file. Try again.'); } }; return (
{tab === 'highlights' && ( <> {/* Colour key: tap a colour to show only that one; "Name colours" lets you say what each means */}
{HIGHLIGHT_COLORS.map((c) => ( ))}
{editing && (
{HIGHLIGHT_COLORS.map((c) => ( ))}
)} {highlights.length === 0 ? (

No highlights yet. Select some words in a verse and pick a colour to save them here.

) : shown.length === 0 ? (

Nothing highlighted in that colour yet.

) : shown.map((h) => (
{onSetHighlightNote && onSetHighlightNote(h.id, text)} />}
))} )} {tab === 'bookmarks' && ( bookmarks.length === 0 ? (

No bookmarks yet. Tap a verse, then the bookmark icon, to save it here.

) : bookmarks.map((e) => (
{onSetBookmarkNote && onSetBookmarkNote(e.key, text)} />}
)) )} {total > 0 && (
Take them with you {exportError && {exportError}}
)}
); }