diff --git a/src/colossiansStudy.tsx b/src/colossiansStudy.tsx index 96531ac..f29afcf 100644 --- a/src/colossiansStudy.tsx +++ b/src/colossiansStudy.tsx @@ -1227,6 +1227,8 @@ export function ColossiansStudySectionPage({ content }: Props) { const [noteLoading, setNoteLoading] = useState(false) const [noteSaving, setNoteSaving] = useState(false) const [noteMessage, setNoteMessage] = useState('') + const [notesModalOpen, setNotesModalOpen] = useState(false) + const [contextNoteMenu, setContextNoteMenu] = useState<{ x: number; y: number; text: string } | null>(null) const [completedSectionIds, setCompletedSectionIds] = useState([]) const [progressLoading, setProgressLoading] = useState(false) const [progressSaving, setProgressSaving] = useState(false) @@ -1392,6 +1394,35 @@ export function ColossiansStudySectionPage({ content }: Props) { } } + function closeNotesModal() { + setNotesModalOpen(false) + } + + function appendSelectedTextToNotes(selectedText: string) { + if (!selectedText.trim()) return + setNoteText(prev => prev ? `${prev.trim()}\n\n${selectedText.trim()}` : selectedText.trim()) + setNotesModalOpen(true) + } + + function handleLessonContentContextMenu(e: React.MouseEvent) { + if (!auth.checked || !auth.authenticated || !isEnrolled || !study || !section) return + const selection = window.getSelection() + const selectedText = selection?.toString().trim() ?? '' + if (!selectedText) { + setContextNoteMenu(null) + return + } + e.preventDefault() + setContextNoteMenu({ x: e.clientX + 4, y: e.clientY + 4, text: selectedText }) + } + + useEffect(() => { + if (!contextNoteMenu) return + const handleClick = () => setContextNoteMenu(null) + window.addEventListener('mousedown', handleClick) + return () => window.removeEventListener('mousedown', handleClick) + }, [contextNoteMenu]) + async function markLessonComplete() { if (!study || !section?.id || progressSaving) return setProgressSaving(true) @@ -1548,7 +1579,7 @@ export function ColossiansStudySectionPage({ content }: Props) { return (
-
+
Back to {study.title} @@ -1685,28 +1716,11 @@ export function ColossiansStudySectionPage({ content }: Props) {

Signed in as {auth.username}

- Open My Notes + My Account
-