fix: improve note interactions and markdown LaTeX support

## Bug Fixes

### Note Card Actions
- Fix broken size change functionality (missing state declaration)
- Implement React 19 useOptimistic for instant UI feedback
- Add startTransition for non-blocking updates
- Ensure smooth animations without page refresh
- All note actions now work: pin, archive, color, size, checklist

### Markdown LaTeX Rendering
- Add remark-math and rehype-katex plugins
- Support inline equations with dollar sign syntax
- Support block equations with double dollar sign syntax
- Import KaTeX CSS for proper styling
- Equations now render correctly instead of showing raw LaTeX

## Technical Details

- Replace undefined currentNote references with optimistic state
- Add optimistic updates before server actions for instant feedback
- Use router.refresh() in transitions for smart cache invalidation
- Install remark-math, rehype-katex, and katex packages

## Testing

- Build passes successfully with no TypeScript errors
- Dev server hot-reloads changes correctly
This commit is contained in:
2026-01-09 22:13:49 +01:00
parent 3c4b9d6176
commit 640fcb26f7
218 changed files with 51363 additions and 902 deletions

View File

@@ -16,14 +16,12 @@ export function useAutoTagging({ content, enabled = true }: UseAutoTaggingProps)
const debouncedContent = useDebounce(content, 1500);
useEffect(() => {
// console.log('AutoTagging Effect:', { enabled, contentLength: debouncedContent?.length });
if (!enabled || !debouncedContent || debouncedContent.length < 10) {
setSuggestions([]);
return;
}
const analyzeContent = async () => {
console.log('🚀 Triggering AI analysis for:', debouncedContent.substring(0, 20) + '...');
setIsAnalyzing(true);
setError(null);
@@ -39,7 +37,6 @@ export function useAutoTagging({ content, enabled = true }: UseAutoTaggingProps)
}
const data = await response.json();
console.log('✅ AI Response:', data);
setSuggestions(data.tags || []);
} catch (err) {
console.error('❌ Auto-tagging error:', err);

View File

@@ -2,11 +2,10 @@
import { useState, useEffect } from 'react';
import { Note } from '@/lib/types';
import { useToast } from '@/components/ui/toast';
import { toast } from 'sonner';
export function useReminderCheck(notes: Note[]) {
const [notifiedReminders, setNotifiedReminders] = useState<Set<string>>(new Set());
const { addToast } = useToast();
useEffect(() => {
const checkReminders = () => {
@@ -26,7 +25,7 @@ export function useReminderCheck(notes: Note[]) {
// const audio = new Audio('/notification.mp3');
// audio.play().catch(e => console.log('Audio play failed', e));
addToast("🔔 Reminder: " + (note.title || "Untitled Note"), "info");
toast.info("🔔 Reminder: " + (note.title || "Untitled Note"));
// Mark as notified in local state
setNotifiedReminders(prev => new Set(prev).add(note.id));
@@ -41,5 +40,5 @@ export function useReminderCheck(notes: Note[]) {
const interval = setInterval(checkReminders, 30000);
return () => clearInterval(interval);
}, [notes, notifiedReminders, addToast]);
}, [notes, notifiedReminders]);
}