diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index 62de722d..63e0d2e6 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -28,6 +28,7 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { const [isCollapsed, setIsCollapsed] = useState(false) const [isHighlightsCollapsed, setIsHighlightsCollapsed] = useState(false) const [viewMode, setViewMode] = useState('cards') + const [showUnderlines, setShowUnderlines] = useState(true) const activeAccount = Hooks.useActiveAccount() const accountManager = Hooks.useAccountManager() @@ -123,6 +124,7 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { markdown={readerContent?.markdown} selectedUrl={selectedUrl} highlights={highlights} + showUnderlines={showUnderlines} />
@@ -133,6 +135,7 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { onToggleCollapse={() => setIsHighlightsCollapsed(!isHighlightsCollapsed)} onSelectUrl={handleSelectUrl} selectedUrl={selectedUrl} + onToggleUnderlines={setShowUnderlines} />
diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index 71e611c0..034acf46 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -13,6 +13,7 @@ interface ContentPanelProps { markdown?: string selectedUrl?: string highlights?: Highlight[] + showUnderlines?: boolean } const ContentPanel: React.FC = ({ @@ -21,7 +22,8 @@ const ContentPanel: React.FC = ({ html, markdown, selectedUrl, - highlights = [] + highlights = [], + showUnderlines = true }) => { const contentRef = useRef(null) @@ -88,13 +90,27 @@ const ContentPanel: React.FC = ({ console.log('🔍 useEffect triggered:', { hasContentRef: !!contentRef.current, relevantHighlightsCount: relevantHighlights.length, - hasHtml: !!html + hasHtml: !!html, + showUnderlines }) - if (!contentRef.current || relevantHighlights.length === 0) { + if (!contentRef.current || relevantHighlights.length === 0 || !showUnderlines) { console.log('⚠️ Skipping highlight application:', { - reason: !contentRef.current ? 'no contentRef' : 'no relevant highlights' + reason: !contentRef.current ? 'no contentRef' : + !showUnderlines ? 'underlines hidden' : + 'no relevant highlights' }) + + // If underlines are hidden, remove any existing highlights + if (!showUnderlines && contentRef.current) { + const marks = contentRef.current.querySelectorAll('mark.content-highlight') + marks.forEach(mark => { + const text = mark.textContent || '' + const textNode = document.createTextNode(text) + mark.parentNode?.replaceChild(textNode, mark) + }) + } + return } @@ -119,7 +135,7 @@ const ContentPanel: React.FC = ({ }, 100) return () => clearTimeout(timer) - }, [relevantHighlights, html]) + }, [relevantHighlights, html, showUnderlines]) const highlightedMarkdown = useMemo(() => { if (!markdown || relevantHighlights.length === 0) return markdown diff --git a/src/components/HighlightsPanel.tsx b/src/components/HighlightsPanel.tsx index 9e743fa9..4b445271 100644 --- a/src/components/HighlightsPanel.tsx +++ b/src/components/HighlightsPanel.tsx @@ -1,6 +1,6 @@ -import React, { useMemo } from 'react' +import React, { useMemo, useState } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faChevronRight, faChevronLeft, faHighlighter } from '@fortawesome/free-solid-svg-icons' +import { faChevronRight, faChevronLeft, faHighlighter, faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons' import { Highlight } from '../types/highlights' import { HighlightItem } from './HighlightItem' @@ -11,6 +11,7 @@ interface HighlightsPanelProps { onToggleCollapse: () => void onSelectUrl?: (url: string) => void selectedUrl?: string + onToggleUnderlines?: (show: boolean) => void } export const HighlightsPanel: React.FC = ({ @@ -19,8 +20,17 @@ export const HighlightsPanel: React.FC = ({ isCollapsed, onToggleCollapse, onSelectUrl, - selectedUrl + selectedUrl, + onToggleUnderlines }) => { + const [showUnderlines, setShowUnderlines] = useState(true) + + const handleToggleUnderlines = () => { + const newValue = !showUnderlines + setShowUnderlines(newValue) + onToggleUnderlines?.(newValue) + } + // Filter highlights to show only those relevant to the current URL const filteredHighlights = useMemo(() => { if (!selectedUrl) return highlights @@ -68,14 +78,26 @@ export const HighlightsPanel: React.FC = ({

Highlights

{!loading && ({filteredHighlights.length})} - +
+ {filteredHighlights.length > 0 && ( + + )} + +
{loading ? ( diff --git a/src/index.css b/src/index.css index 45439d29..68a9fb31 100644 --- a/src/index.css +++ b/src/index.css @@ -1136,6 +1136,13 @@ body { font-size: 0.875rem; } +.highlights-actions { + display: flex; + align-items: center; + gap: 0.5rem; +} + +.toggle-underlines-btn, .toggle-highlights-btn { background: transparent; color: #ddd; @@ -1151,11 +1158,13 @@ body { transition: all 0.2s ease; } +.toggle-underlines-btn:hover, .toggle-highlights-btn:hover { background: #2a2a2a; color: #fff; } +.toggle-underlines-btn:active, .toggle-highlights-btn:active { transform: translateY(1px); }