diff --git a/package.json b/package.json index 67160fb..0b18cfa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nextcloud-notes-tauri", "private": true, - "version": "0.1.0", + "version": "0.1.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3c7d1d9..b31cc83 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Nextcloud Notes", - "version": "0.1.0", + "version": "0.1.1", "identifier": "com.davidrelich.nextcloud-notes", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/api/nextcloud.ts b/src/api/nextcloud.ts index d60cf1a..8243b4b 100644 --- a/src/api/nextcloud.ts +++ b/src/api/nextcloud.ts @@ -77,7 +77,7 @@ export class NextcloudAPI { webdavPath += `/${path}`; const url = `${this.serverURL}${webdavPath}`; - console.log('Fetching attachment via WebDAV:', url); + console.log(`[Note ${_noteId}] Fetching attachment via WebDAV:`, url); const response = await tauriFetch(url, { headers: { diff --git a/src/components/CategoriesSidebar.tsx b/src/components/CategoriesSidebar.tsx index 9ef03b7..2b6ec4c 100644 --- a/src/components/CategoriesSidebar.tsx +++ b/src/components/CategoriesSidebar.tsx @@ -58,6 +58,7 @@ export function CategoriesSidebar({ }: CategoriesSidebarProps) { const [isCreating, setIsCreating] = useState(false); const [newCategoryName, setNewCategoryName] = useState(''); + const [isSettingsCollapsed, setIsSettingsCollapsed] = useState(true); const inputRef = useRef(null); useEffect(() => { @@ -185,27 +186,40 @@ export function CategoriesSidebar({ {/* User Info and Settings */} -
-
+
+
{username.charAt(0).toUpperCase()}
{username}
- +
+ + +
- {/* Theme Toggle */} -
+ {!isSettingsCollapsed && ( +
+ {/* Theme Toggle */} +
Theme
- {/* Font Settings */} -
+ {/* Font Settings */} +
Fonts - {/* Editor Font */} -
-
- - - - Editor -
-
- - -
-
+ {/* Editor Font */} +
+
+ + + + Editor +
+
+ + +
+
- {/* Preview Font */} -
-
- - - - - Preview -
-
- - + {/* Preview Font */} +
+
+ + + + + Preview +
+
+ + +
+
-
+ )}
); diff --git a/src/components/NoteEditor.tsx b/src/components/NoteEditor.tsx index eae5e3c..784fde2 100644 --- a/src/components/NoteEditor.tsx +++ b/src/components/NoteEditor.tsx @@ -77,13 +77,23 @@ export function NoteEditor({ note, onUpdateNote, onUnsavedChanges, categories, i return; } + // Guard: Only process if localContent has been updated for the current note + // This prevents processing stale content from the previous note + if (previousNoteIdRef.current !== note.id) { + console.log(`[Note ${note.id}] Skipping image processing - waiting for content to sync (previousNoteIdRef: ${previousNoteIdRef.current})`); + return; + } + const processImages = async () => { + console.log(`[Note ${note.id}] Processing images in preview mode. Content length: ${localContent.length}`); setIsLoadingImages(true); + setProcessedContent(''); // Clear old content immediately // Find all image references in markdown: ![alt](path) const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/g; let content = localContent; const matches = [...localContent.matchAll(imageRegex)]; + console.log(`[Note ${note.id}] Found ${matches.length} images to process`); for (const match of matches) { const [fullMatch, alt, imagePath] = match; @@ -121,11 +131,13 @@ export function NoteEditor({ note, onUpdateNote, onUnsavedChanges, categories, i useEffect(() => { const loadNewNote = () => { if (note) { + console.log(`[Note ${note.id}] Loading note. Title: "${note.title}", Content length: ${note.content.length}`); setLocalTitle(note.title); setLocalContent(note.content); setLocalCategory(note.category || ''); setLocalFavorite(note.favorite); setHasUnsavedChanges(false); + setProcessedContent(''); // Clear preview content immediately const firstLine = note.content.split('\n')[0].replace(/^#+\s*/, '').trim(); const titleMatchesFirstLine = note.title === firstLine || note.title === firstLine.substring(0, 50); @@ -136,10 +148,13 @@ export function NoteEditor({ note, onUpdateNote, onUnsavedChanges, categories, i }; if (previousNoteIdRef.current !== null && previousNoteIdRef.current !== note?.id) { + console.log(`Switching from note ${previousNoteIdRef.current} to note ${note?.id}`); + // Clear preview content immediately when switching notes + setProcessedContent(''); if (hasUnsavedChanges) { handleSave(); } - setTimeout(loadNewNote, 100); + loadNewNote(); } else { loadNewNote(); } diff --git a/src/components/NotesList.tsx b/src/components/NotesList.tsx index 5e9765c..2c787b7 100644 --- a/src/components/NotesList.tsx +++ b/src/components/NotesList.tsx @@ -30,6 +30,9 @@ export function NotesList({ }: NotesListProps) { const [isSyncing, setIsSyncing] = React.useState(false); const [deleteClickedId, setDeleteClickedId] = React.useState(null); + const [width, setWidth] = React.useState(320); + const [isResizing, setIsResizing] = React.useState(false); + const containerRef = React.useRef(null); const handleSync = async () => { setIsSyncing(true); @@ -37,6 +40,34 @@ export function NotesList({ setTimeout(() => setIsSyncing(false), 500); }; + React.useEffect(() => { + const handleMouseMove = (e: MouseEvent) => { + if (!isResizing) return; + const newWidth = e.clientX - (containerRef.current?.getBoundingClientRect().left || 0); + if (newWidth >= 240 && newWidth <= 600) { + setWidth(newWidth); + } + }; + + const handleMouseUp = () => { + setIsResizing(false); + }; + + if (isResizing) { + document.addEventListener('mousemove', handleMouseMove); + document.addEventListener('mouseup', handleMouseUp); + document.body.style.cursor = 'ew-resize'; + document.body.style.userSelect = 'none'; + } + + return () => { + document.removeEventListener('mousemove', handleMouseMove); + document.removeEventListener('mouseup', handleMouseUp); + document.body.style.cursor = ''; + document.body.style.userSelect = ''; + }; + }, [isResizing]); + const handleDeleteClick = (note: Note, e: React.MouseEvent) => { e.stopPropagation(); @@ -79,7 +110,11 @@ export function NotesList({ }; return ( -
+

Notes

@@ -207,6 +242,17 @@ export function NotesList({ )) )}
+ + {/* Resize Handle */} +
{ + e.preventDefault(); + setIsResizing(true); + }} + > +
+
); }