chore: public polish — remove stray fix scripts, move internal docs, add LICENSE
This commit is contained in:
@@ -44,3 +44,7 @@ pocketbase/pb_data/
|
|||||||
.wrangler/
|
.wrangler/
|
||||||
.vinext/
|
.vinext/
|
||||||
pb_data/
|
pb_data/
|
||||||
|
# Build artifacts
|
||||||
|
*.tsbuildinfo
|
||||||
|
# One-off fix scripts
|
||||||
|
fix_*.py
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Matt Batchelder
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Remove all setEditorContent calls
|
|
||||||
content = content.replace(' setEditorContent("");\n', '', 1)
|
|
||||||
content = content.replace(' setEditorContent(detail.content || "");\n', '', 1)
|
|
||||||
content = content.replace(' setEditorContent(note.content || "");\n', '', 1)
|
|
||||||
|
|
||||||
# Remove editorContent state
|
|
||||||
content = content.replace(' const [editorContent, setEditorContent] = useState("");\n', '', 1)
|
|
||||||
|
|
||||||
# Remove saveTimerRef
|
|
||||||
content = content.replace(' const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n', '', 1)
|
|
||||||
|
|
||||||
# Remove selectedNoteRef
|
|
||||||
content = content.replace(' const selectedNoteRef = useRef<Note | null>(null);\n', '', 1)
|
|
||||||
|
|
||||||
# Remove selectedNoteRef.current assignments
|
|
||||||
content = content.replace(' selectedNoteRef.current = detail;\n', '', 1)
|
|
||||||
content = content.replace(' selectedNoteRef.current = note;\n', '', 1)
|
|
||||||
content = content.replace(' selectedNoteRef.current = note;\n', '', 1)
|
|
||||||
|
|
||||||
# Remove handleContentChange
|
|
||||||
old = ''' const handleContentChange = useCallback((html: string) => {
|
|
||||||
if (saveTimerRef.current) clearTimeout(saveTimerRef.current);
|
|
||||||
saveTimerRef.current = setTimeout(() => {
|
|
||||||
const note = selectedNoteRef.current;
|
|
||||||
if (note) {
|
|
||||||
updateMutation.mutate({ id: note.id, data: { content: html } });
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
}, [updateMutation]);'''
|
|
||||||
|
|
||||||
content = content.replace(old, '', 1)
|
|
||||||
|
|
||||||
# Update NoteEditor usage
|
|
||||||
old_editor = ' <NoteEditor key={selectedNote?.id || \'none\'} initialContent={editorContent} onSave={handleContentChange} />'
|
|
||||||
new_editor = ' <NoteEditor key={selectedNote?.id || \'none\'} initialContent={selectedNote?.content || \'\'} onSave={(html) => { if (selectedNote) { updateMutation.mutate({ id: selectedNote.id, data: { content: html } }); } }} />'
|
|
||||||
content = content.replace(old_editor, new_editor, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Replace NoteEditor to use ref-based onChange (no re-render on keystroke)
|
|
||||||
old_editor = '''const NoteEditor = memo(function NoteEditor({ content, onChange, placeholder = "Start writing..." }: { content: string; onChange: (html: string) => void; placeholder?: string }) {
|
|
||||||
const editorRef = useRef<HTMLDivElement>(null);
|
|
||||||
const [isPlaceholder, setIsPlaceholder] = useState(!content);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (editorRef.current && !editorRef.current.innerHTML) {
|
|
||||||
editorRef.current.innerHTML = content || "";
|
|
||||||
}
|
|
||||||
}, [content]);
|
|
||||||
|
|
||||||
const handleInput = () => {
|
|
||||||
const html = editorRef.current?.innerHTML || "";
|
|
||||||
setIsPlaceholder(!html || html === "<br>");
|
|
||||||
onChange(html);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="relative min-h-[300px]">
|
|
||||||
{isPlaceholder && (
|
|
||||||
<div className="absolute top-0 left-0 text-muted-foreground pointer-events-none p-3 text-sm">{placeholder}</div>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
ref={editorRef}
|
|
||||||
contentEditable
|
|
||||||
className="prose prose-sm dark:prose-invert max-w-none p-3 focus:outline-none min-h-[300px]"
|
|
||||||
onInput={handleInput}
|
|
||||||
suppressContentEditableWarning
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});'''
|
|
||||||
|
|
||||||
new_editor = '''const NoteEditor = memo(function NoteEditor({ content, onChange, placeholder = "Start writing..." }: { content: string; onChange: (html: string) => void; placeholder?: string }) {
|
|
||||||
const editorRef = useRef<HTMLDivElement>(null);
|
|
||||||
const onChangeRef = useRef(onChange);
|
|
||||||
onChangeRef.current = onChange;
|
|
||||||
const [isPlaceholder, setIsPlaceholder] = useState(!content);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (editorRef.current && !editorRef.current.innerHTML) {
|
|
||||||
editorRef.current.innerHTML = content || "";
|
|
||||||
}
|
|
||||||
}, [content]);
|
|
||||||
|
|
||||||
const handleInput = useCallback(() => {
|
|
||||||
const html = editorRef.current?.innerHTML || "";
|
|
||||||
setIsPlaceholder(!html || html === "<br>");
|
|
||||||
onChangeRef.current(html);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="relative min-h-[300px]">
|
|
||||||
{isPlaceholder && (
|
|
||||||
<div className="absolute top-0 left-0 text-muted-foreground pointer-events-none p-3 text-sm">{placeholder}</div>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
ref={editorRef}
|
|
||||||
contentEditable
|
|
||||||
className="prose prose-sm dark:prose-invert max-w-none p-3 focus:outline-none min-h-[300px]"
|
|
||||||
onInput={handleInput}
|
|
||||||
suppressContentEditableWarning
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});'''
|
|
||||||
|
|
||||||
content = content.replace(old_editor, new_editor, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Replace the title input section to use uncontrolled input with ref
|
|
||||||
old_title_section = ''' <div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<Input
|
|
||||||
value={titleDraft}
|
|
||||||
onChange={(e) => handleTitleChange(e.target.value)}
|
|
||||||
onBlur={handleTitleBlur}
|
|
||||||
className="text-lg font-semibold border-0 focus-visible:ring-0 px-0"
|
|
||||||
/>'''
|
|
||||||
|
|
||||||
new_title_section = ''' <div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<input
|
|
||||||
key={selectedNote?.id || 'none'}
|
|
||||||
defaultValue={selectedNote?.title || ''}
|
|
||||||
onBlur={(e) => {
|
|
||||||
if (selectedNote && e.target.value !== selectedNote.title) {
|
|
||||||
updateMutation.mutate({ id: selectedNote.id, data: { title: e.target.value } });
|
|
||||||
setSelectedNote({ ...selectedNote, title: e.target.value });
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="flex h-9 w-full rounded-md border-0 bg-transparent px-0 py-1 text-lg font-semibold text-base shadow-none transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50"
|
|
||||||
/>'''
|
|
||||||
|
|
||||||
content = content.replace(old_title_section, new_title_section, 1)
|
|
||||||
|
|
||||||
# Remove unused handleTitleChange and handleTitleBlur
|
|
||||||
old_handle = ''' const handleTitleChange = (title: string) => {
|
|
||||||
setTitleDraft(title);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleTitleBlur = () => {
|
|
||||||
if (selectedNote && titleDraft !== selectedNote.title) {
|
|
||||||
updateMutation.mutate({ id: selectedNote.id, data: { title: titleDraft } });
|
|
||||||
setSelectedNote({ ...selectedNote, title: titleDraft });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
'''
|
|
||||||
content = content.replace(old_handle, '', 1)
|
|
||||||
|
|
||||||
# Remove unused titleDraft state
|
|
||||||
content = content.replace(' const [titleDraft, setTitleDraft] = useState("");\n', '', 1)
|
|
||||||
|
|
||||||
# Remove unused titleTimerRef
|
|
||||||
content = content.replace(' const titleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n', '', 1)
|
|
||||||
|
|
||||||
# Remove setTitleDraft calls from selectNote
|
|
||||||
content = content.replace(' setTitleDraft(detail.title);\n', '', 1)
|
|
||||||
content = content.replace(' setTitleDraft(note.title);\n', '', 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
old = '<input\n key={selectedNote?.id || \'none\'}\n defaultValue={selectedNote?.title || \'\'}\n onBlur={(e) => {'
|
|
||||||
new = '<input\n key={selectedNote?.id || \'none\'}\n defaultValue={selectedNote?.title || \'\'}\n onMouseDown={(e) => e.stopPropagation()}\n onBlur={(e) => {'
|
|
||||||
|
|
||||||
content = content.replace(old, new, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Add a memoized TitleInput component after NoteEditor
|
|
||||||
old = '''function NotesPage() {'''
|
|
||||||
new = '''// Memoized title input that doesn't re-render when parent re-renders
|
|
||||||
const TitleInput = memo(function TitleInput({ note, onSave }: { note: Note | null; onSave: (id: string, title: string) => void }) {
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (inputRef.current) {
|
|
||||||
inputRef.current.value = note?.title || '';
|
|
||||||
}
|
|
||||||
}, [note?.id]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
key={note?.id || 'none'}
|
|
||||||
defaultValue={note?.title || ''}
|
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
|
||||||
onBlur={(e) => {
|
|
||||||
if (note && e.target.value !== note.title) {
|
|
||||||
onSave(note.id, e.target.value);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="flex h-9 w-full rounded-md border-0 bg-transparent px-0 py-1 text-lg font-semibold text-base shadow-none transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
function NotesPage() {'''
|
|
||||||
|
|
||||||
content = content.replace(old, new, 1)
|
|
||||||
|
|
||||||
# Replace the title input section
|
|
||||||
old_title = ''' <input
|
|
||||||
key={selectedNote?.id || 'none'}
|
|
||||||
defaultValue={selectedNote?.title || ''}
|
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
|
||||||
onBlur={(e) => {
|
|
||||||
if (selectedNote && e.target.value !== selectedNote.title) {
|
|
||||||
updateMutation.mutate({ id: selectedNote.id, data: { title: e.target.value } });
|
|
||||||
setSelectedNote({ ...selectedNote, title: e.target.value });
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="flex h-9 w-full rounded-md border-0 bg-transparent px-0 py-1 text-lg font-semibold text-base shadow-none transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50"
|
|
||||||
/>'''
|
|
||||||
|
|
||||||
new_title = ''' <TitleInput
|
|
||||||
note={selectedNote}
|
|
||||||
onSave={(id, title) => {
|
|
||||||
updateMutation.mutate({ id, data: { title } });
|
|
||||||
setSelectedNote({ ...selectedNote, title } as Note);
|
|
||||||
}}
|
|
||||||
/>'''
|
|
||||||
|
|
||||||
content = content.replace(old_title, new_title, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
-354
@@ -1,354 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Replace the entire NotesPage function with a version that uses a separate memoized right pane
|
|
||||||
old = '''function NotesPage() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [selectedNoteId, setSelectedNoteId] = useState<string | null>(null);
|
|
||||||
const [showBacklinks, setShowBacklinks] = useState(false);
|
|
||||||
const [showVersions, setShowVersions] = useState(false);
|
|
||||||
const selectedNoteRef = useRef<Note | null>(null);
|
|
||||||
|
|
||||||
useRealtime({ enabled: true });
|
|
||||||
|
|
||||||
const { data: notesData, isLoading } = useApiQuery<PaginatedResponse<Note>>(
|
|
||||||
["notes", search],
|
|
||||||
"/notes?limit=200" + (search ? "&search=" + encodeURIComponent(search) : "")
|
|
||||||
);
|
|
||||||
|
|
||||||
const notes = notesData?.items || [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
|
||||||
mutationFn: () => api.post<Note>("/notes", { title: "Untitled", content: "" }),
|
|
||||||
onSuccess: (note) => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
|
||||||
mutationFn: ({ id, data }: { id: string; data: any }) => api.patch<Note>("/notes/" + id, data),
|
|
||||||
onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["notes"] }); },
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: (id: string) => api.delete("/notes/" + id),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = null;
|
|
||||||
setSelectedNoteId(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectNote = async (note: Note) => {
|
|
||||||
try {
|
|
||||||
const detail = await api.get<Note>("/notes/" + note.id);
|
|
||||||
selectedNoteRef.current = detail;
|
|
||||||
} catch {
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
}
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
setShowBacklinks(false);
|
|
||||||
setShowVersions(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedNote = selectedNoteRef.current;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex h-[calc(100vh-8rem)] -m-4 md:-m-6">
|
|
||||||
{/* Left pane - note list */}
|
|
||||||
<div className="w-72 border-r flex flex-col shrink-0">
|
|
||||||
<div className="p-3 border-b">
|
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input placeholder="Search notes..." value={search} onChange={(e) => setSearch(e.target.value)} className="pl-8" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-2">
|
|
||||||
<Button size="sm" className="w-full" onClick={() => createMutation.mutate()} aria-label="New note">
|
|
||||||
<Plus className="h-4 w-4 mr-2" />New Note
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">Loading...</div>
|
|
||||||
) : notes.length === 0 ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">No notes yet.</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-0.5 p-2">
|
|
||||||
{notes.map((note) => (
|
|
||||||
<button
|
|
||||||
key={note.id}
|
|
||||||
onClick={() => selectNote(note)}
|
|
||||||
className={cn(
|
|
||||||
"w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
|
|
||||||
selectedNoteId === note.id ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{note.isPinned && <Pin className="h-3 w-3 shrink-0 text-muted-foreground" />}
|
|
||||||
<span className="truncate font-medium">{note.title}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground mt-0.5">
|
|
||||||
{new Date(note.updatedAt).toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right pane - editor */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
{selectedNote ? (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<NoteTitleInput key={selectedNote.id} noteId={selectedNote.id} initialTitle={selectedNote.title} />
|
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowBacklinks(!showBacklinks)} aria-label="Backlinks">
|
|
||||||
<LinkIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowVersions(!showVersions)} aria-label="Version history">
|
|
||||||
<History className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" aria-label="Delete note">
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Delete Note</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>Are you sure you want to delete "{selectedNote.title}"?</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={() => deleteMutation.mutate(selectedNote.id)} className="bg-destructive text-destructive-foreground">Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 overflow-auto">
|
|
||||||
<NoteEditor key={selectedNote.id} initialContent={selectedNote.content || ''} onSave={(html) => { if (selectedNoteRef.current) { updateMutation.mutate({ id: selectedNoteRef.current.id, data: { content: html } }); } }} />
|
|
||||||
</div>
|
|
||||||
{/* Backlinks section */}
|
|
||||||
{showBacklinks && selectedNote.backlinks && selectedNote.backlinks.length > 0 && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Linked from</h4>
|
|
||||||
<div className="space-y-1">
|
|
||||||
{selectedNote.backlinks.map((bl) => (
|
|
||||||
<div key={bl.noteId} className="text-sm text-muted-foreground hover:text-foreground cursor-pointer">
|
|
||||||
{bl.noteTitle}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Version history */}
|
|
||||||
{showVersions && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Version History</h4>
|
|
||||||
<p className="text-xs text-muted-foreground">Version history available via API.</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center flex-1 text-muted-foreground">
|
|
||||||
<div className="text-center">
|
|
||||||
<FileText className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
||||||
<p>Select a note or create a new one</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}'''
|
|
||||||
|
|
||||||
new = '''// Memoized right pane - only re-renders when note changes, not on parent re-renders
|
|
||||||
const NoteEditorPane = memo(function NoteEditorPane({ note, onDelete }: { note: Note; onDelete: (id: string) => void }) {
|
|
||||||
const [showBacklinks, setShowBacklinks] = useState(false);
|
|
||||||
const [showVersions, setShowVersions] = useState(false);
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
|
||||||
mutationFn: ({ id, data }: { id: string; data: any }) => api.patch<Note>("/notes/" + id, data),
|
|
||||||
onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["notes"] }); },
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<NoteTitleInput key={note.id} noteId={note.id} initialTitle={note.title} />
|
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowBacklinks(!showBacklinks)} aria-label="Backlinks">
|
|
||||||
<LinkIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowVersions(!showVersions)} aria-label="Version history">
|
|
||||||
<History className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" aria-label="Delete note">
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Delete Note</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>Are you sure you want to delete "{note.title}"?</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={() => onDelete(note.id)} className="bg-destructive text-destructive-foreground">Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 overflow-auto">
|
|
||||||
<NoteEditor key={note.id} initialContent={note.content || ''} onSave={(html) => { updateMutation.mutate({ id: note.id, data: { content: html } }); }} />
|
|
||||||
</div>
|
|
||||||
{/* Backlinks section */}
|
|
||||||
{showBacklinks && note.backlinks && note.backlinks.length > 0 && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Linked from</h4>
|
|
||||||
<div className="space-y-1">
|
|
||||||
{note.backlinks.map((bl) => (
|
|
||||||
<div key={bl.noteId} className="text-sm text-muted-foreground hover:text-foreground cursor-pointer">
|
|
||||||
{bl.noteTitle}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Version history */}
|
|
||||||
{showVersions && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Version History</h4>
|
|
||||||
<p className="text-xs text-muted-foreground">Version history available via API.</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
function NotesPage() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [selectedNoteId, setSelectedNoteId] = useState<string | null>(null);
|
|
||||||
const selectedNoteRef = useRef<Note | null>(null);
|
|
||||||
|
|
||||||
useRealtime({ enabled: true });
|
|
||||||
|
|
||||||
const { data: notesData, isLoading } = useApiQuery<PaginatedResponse<Note>>(
|
|
||||||
["notes", search],
|
|
||||||
"/notes?limit=200" + (search ? "&search=" + encodeURIComponent(search) : "")
|
|
||||||
);
|
|
||||||
|
|
||||||
const notes = notesData?.items || [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
|
||||||
mutationFn: () => api.post<Note>("/notes", { title: "Untitled", content: "" }),
|
|
||||||
onSuccess: (note) => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: (id: string) => api.delete("/notes/" + id),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = null;
|
|
||||||
setSelectedNoteId(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectNote = async (note: Note) => {
|
|
||||||
try {
|
|
||||||
const detail = await api.get<Note>("/notes/" + note.id);
|
|
||||||
selectedNoteRef.current = detail;
|
|
||||||
} catch {
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
}
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedNote = selectedNoteRef.current;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex h-[calc(100vh-8rem)] -m-4 md:-m-6">
|
|
||||||
{/* Left pane - note list */}
|
|
||||||
<div className="w-72 border-r flex flex-col shrink-0">
|
|
||||||
<div className="p-3 border-b">
|
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input placeholder="Search notes..." value={search} onChange={(e) => setSearch(e.target.value)} className="pl-8" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-2">
|
|
||||||
<Button size="sm" className="w-full" onClick={() => createMutation.mutate()} aria-label="New note">
|
|
||||||
<Plus className="h-4 w-4 mr-2" />New Note
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">Loading...</div>
|
|
||||||
) : notes.length === 0 ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">No notes yet.</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-0.5 p-2">
|
|
||||||
{notes.map((note) => (
|
|
||||||
<button
|
|
||||||
key={note.id}
|
|
||||||
onClick={() => selectNote(note)}
|
|
||||||
className={cn(
|
|
||||||
"w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
|
|
||||||
selectedNoteId === note.id ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{note.isPinned && <Pin className="h-3 w-3 shrink-0 text-muted-foreground" />}
|
|
||||||
<span className="truncate font-medium">{note.title}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground mt-0.5">
|
|
||||||
{new Date(note.updatedAt).toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right pane - editor (memoized, won't re-render on parent state changes) */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
{selectedNote ? (
|
|
||||||
<NoteEditorPane key={selectedNote.id} note={selectedNote} onDelete={(id) => deleteMutation.mutate(id)} />
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center flex-1 text-muted-foreground">
|
|
||||||
<div className="text-center">
|
|
||||||
<FileText className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
||||||
<p>Select a note or create a new one</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}'''
|
|
||||||
|
|
||||||
content = content.replace(old, new, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
-354
@@ -1,354 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Replace the entire NotesPage function and add NoteEditorPane
|
|
||||||
old = '''function NotesPage() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [selectedNoteId, setSelectedNoteId] = useState<string | null>(null);
|
|
||||||
const [showBacklinks, setShowBacklinks] = useState(false);
|
|
||||||
const [showVersions, setShowVersions] = useState(false);
|
|
||||||
const selectedNoteRef = useRef<Note | null>(null);
|
|
||||||
|
|
||||||
useRealtime({ enabled: true });
|
|
||||||
|
|
||||||
const { data: notesData, isLoading } = useApiQuery<PaginatedResponse<Note>>(
|
|
||||||
["notes", search],
|
|
||||||
"/notes?limit=200" + (search ? "&search=" + encodeURIComponent(search) : "")
|
|
||||||
);
|
|
||||||
|
|
||||||
const notes = notesData?.items || [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
|
||||||
mutationFn: () => api.post<Note>("/notes", { title: "Untitled", content: "" }),
|
|
||||||
onSuccess: (note) => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
|
||||||
mutationFn: ({ id, data }: { id: string; data: any }) => api.patch<Note>("/notes/" + id, data),
|
|
||||||
onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["notes"] }); },
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: (id: string) => api.delete("/notes/" + id),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = null;
|
|
||||||
setSelectedNoteId(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectNote = async (note: Note) => {
|
|
||||||
try {
|
|
||||||
const detail = await api.get<Note>("/notes/" + note.id);
|
|
||||||
selectedNoteRef.current = detail;
|
|
||||||
} catch {
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
}
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
setShowBacklinks(false);
|
|
||||||
setShowVersions(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedNote = selectedNoteRef.current;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex h-[calc(100vh-8rem)] -m-4 md:-m-6">
|
|
||||||
{/* Left pane - note list */}
|
|
||||||
<div className="w-72 border-r flex flex-col shrink-0">
|
|
||||||
<div className="p-3 border-b">
|
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input placeholder="Search notes..." value={search} onChange={(e) => setSearch(e.target.value)} className="pl-8" tabIndex={-1} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-2">
|
|
||||||
<Button size="sm" className="w-full" onClick={() => createMutation.mutate()} aria-label="New note">
|
|
||||||
<Plus className="h-4 w-4 mr-2" />New Note
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">Loading...</div>
|
|
||||||
) : notes.length === 0 ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">No notes yet.</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-0.5 p-2">
|
|
||||||
{notes.map((note) => (
|
|
||||||
<button
|
|
||||||
key={note.id}
|
|
||||||
onClick={() => selectNote(note)}
|
|
||||||
className={cn(
|
|
||||||
"w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
|
|
||||||
selectedNoteId === note.id ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{note.isPinned && <Pin className="h-3 w-3 shrink-0 text-muted-foreground" />}
|
|
||||||
<span className="truncate font-medium">{note.title}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground mt-0.5">
|
|
||||||
{new Date(note.updatedAt).toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right pane - editor */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
{selectedNote ? (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<NoteTitleInput key={selectedNote.id} noteId={selectedNote.id} initialTitle={selectedNote.title} />
|
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowBacklinks(!showBacklinks)} aria-label="Backlinks">
|
|
||||||
<LinkIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowVersions(!showVersions)} aria-label="Version history">
|
|
||||||
<History className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" aria-label="Delete note">
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Delete Note</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>Are you sure you want to delete "{selectedNote.title}"?</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={() => deleteMutation.mutate(selectedNote.id)} className="bg-destructive text-destructive-foreground">Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 overflow-auto">
|
|
||||||
<NoteEditor key={selectedNote.id} initialContent={selectedNote.content || ''} onSave={(html) => { if (selectedNoteRef.current) { updateMutation.mutate({ id: selectedNoteRef.current.id, data: { content: html } }); } }} />
|
|
||||||
</div>
|
|
||||||
{/* Backlinks section */}
|
|
||||||
{showBacklinks && selectedNote.backlinks && selectedNote.backlinks.length > 0 && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Linked from</h4>
|
|
||||||
<div className="space-y-1">
|
|
||||||
{selectedNote.backlinks.map((bl) => (
|
|
||||||
<div key={bl.noteId} className="text-sm text-muted-foreground hover:text-foreground cursor-pointer">
|
|
||||||
{bl.noteTitle}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Version history */}
|
|
||||||
{showVersions && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Version History</h4>
|
|
||||||
<p className="text-xs text-muted-foreground">Version history available via API.</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center flex-1 text-muted-foreground">
|
|
||||||
<div className="text-center">
|
|
||||||
<FileText className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
||||||
<p>Select a note or create a new one</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}'''
|
|
||||||
|
|
||||||
new = '''// Memoized right pane - only re-renders when note changes, not on parent re-renders
|
|
||||||
const NoteEditorPane = memo(function NoteEditorPane({ note, onDelete }: { note: Note; onDelete: (id: string) => void }) {
|
|
||||||
const [showBacklinks, setShowBacklinks] = useState(false);
|
|
||||||
const [showVersions, setShowVersions] = useState(false);
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
|
||||||
mutationFn: ({ id, data }: { id: string; data: any }) => api.patch<Note>("/notes/" + id, data),
|
|
||||||
onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["notes"] }); },
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<NoteTitleInput key={note.id} noteId={note.id} initialTitle={note.title} />
|
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowBacklinks(!showBacklinks)} aria-label="Backlinks">
|
|
||||||
<LinkIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowVersions(!showVersions)} aria-label="Version history">
|
|
||||||
<History className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" aria-label="Delete note">
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Delete Note</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>Are you sure you want to delete "{note.title}"?</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={() => onDelete(note.id)} className="bg-destructive text-destructive-foreground">Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 overflow-auto">
|
|
||||||
<NoteEditor key={note.id} initialContent={note.content || ''} onSave={(html) => { updateMutation.mutate({ id: note.id, data: { content: html } }); }} />
|
|
||||||
</div>
|
|
||||||
{/* Backlinks section */}
|
|
||||||
{showBacklinks && note.backlinks && note.backlinks.length > 0 && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Linked from</h4>
|
|
||||||
<div className="space-y-1">
|
|
||||||
{note.backlinks.map((bl) => (
|
|
||||||
<div key={bl.noteId} className="text-sm text-muted-foreground hover:text-foreground cursor-pointer">
|
|
||||||
{bl.noteTitle}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Version history */}
|
|
||||||
{showVersions && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Version History</h4>
|
|
||||||
<p className="text-xs text-muted-foreground">Version history available via API.</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
function NotesPage() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [selectedNoteId, setSelectedNoteId] = useState<string | null>(null);
|
|
||||||
const selectedNoteRef = useRef<Note | null>(null);
|
|
||||||
|
|
||||||
useRealtime({ enabled: true });
|
|
||||||
|
|
||||||
const { data: notesData, isLoading } = useApiQuery<PaginatedResponse<Note>>(
|
|
||||||
["notes", search],
|
|
||||||
"/notes?limit=200" + (search ? "&search=" + encodeURIComponent(search) : "")
|
|
||||||
);
|
|
||||||
|
|
||||||
const notes = notesData?.items || [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
|
||||||
mutationFn: () => api.post<Note>("/notes", { title: "Untitled", content: "" }),
|
|
||||||
onSuccess: (note) => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: (id: string) => api.delete("/notes/" + id),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = null;
|
|
||||||
setSelectedNoteId(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectNote = async (note: Note) => {
|
|
||||||
try {
|
|
||||||
const detail = await api.get<Note>("/notes/" + note.id);
|
|
||||||
selectedNoteRef.current = detail;
|
|
||||||
} catch {
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
}
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedNote = selectedNoteRef.current;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex h-[calc(100vh-8rem)] -m-4 md:-m-6">
|
|
||||||
{/* Left pane - note list */}
|
|
||||||
<div className="w-72 border-r flex flex-col shrink-0">
|
|
||||||
<div className="p-3 border-b">
|
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input placeholder="Search notes..." value={search} onChange={(e) => setSearch(e.target.value)} className="pl-8" tabIndex={-1} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-2">
|
|
||||||
<Button size="sm" className="w-full" onClick={() => createMutation.mutate()} aria-label="New note">
|
|
||||||
<Plus className="h-4 w-4 mr-2" />New Note
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">Loading...</div>
|
|
||||||
) : notes.length === 0 ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">No notes yet.</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-0.5 p-2">
|
|
||||||
{notes.map((note) => (
|
|
||||||
<button
|
|
||||||
key={note.id}
|
|
||||||
onClick={() => selectNote(note)}
|
|
||||||
className={cn(
|
|
||||||
"w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
|
|
||||||
selectedNoteId === note.id ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{note.isPinned && <Pin className="h-3 w-3 shrink-0 text-muted-foreground" />}
|
|
||||||
<span className="truncate font-medium">{note.title}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground mt-0.5">
|
|
||||||
{new Date(note.updatedAt).toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right pane - editor (memoized, won't re-render on parent state changes) */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
{selectedNote ? (
|
|
||||||
<NoteEditorPane key={selectedNote.id} note={selectedNote} onDelete={(id) => deleteMutation.mutate(id)} />
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center flex-1 text-muted-foreground">
|
|
||||||
<div className="text-center">
|
|
||||||
<FileText className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
||||||
<p>Select a note or create a new one</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}'''
|
|
||||||
|
|
||||||
content = content.replace(old, new, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
old = 'className=flex h-9 w-full rounded-md border-0 bg-transparent px-0 py-1 text-lg font-semibold text-base shadow-none transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50'
|
|
||||||
new = 'className="flex h-9 w-full rounded-md border-0 bg-transparent px-0 py-1 text-lg font-semibold text-base shadow-none transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50"'
|
|
||||||
|
|
||||||
count = content.count(old)
|
|
||||||
print(f'Found {count} occurrences')
|
|
||||||
|
|
||||||
content = content.replace(old, new, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
-340
@@ -1,340 +0,0 @@
|
|||||||
import sys
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
old = '''function NotesPage() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [selectedNote, setSelectedNote] = useState<Note | null>(null);
|
|
||||||
const [showBacklinks, setShowBacklinks] = useState(false);
|
|
||||||
const [showVersions, setShowVersions] = useState(false);
|
|
||||||
|
|
||||||
useRealtime({ enabled: true });
|
|
||||||
|
|
||||||
const { data: notesData, isLoading } = useApiQuery<PaginatedResponse<Note>>(
|
|
||||||
["notes", search],
|
|
||||||
"/notes?limit=200" + (search ? "&search=" + encodeURIComponent(search) : "")
|
|
||||||
);
|
|
||||||
|
|
||||||
const notes = notesData?.items || [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
|
||||||
mutationFn: () => api.post<Note>("/notes", { title: "Untitled", content: "" }),
|
|
||||||
onSuccess: (note) => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
setSelectedNote(note);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
|
||||||
mutationFn: ({ id, data }: { id: string; data: any }) => api.patch<Note>("/notes/" + id, data),
|
|
||||||
onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["notes"] }); },
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: (id: string) => api.delete("/notes/" + id),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
setSelectedNote(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectNote = async (note: Note) => {
|
|
||||||
try {
|
|
||||||
const detail = await api.get<Note>("/notes/" + note.id);
|
|
||||||
setSelectedNote(detail);
|
|
||||||
} catch {
|
|
||||||
setSelectedNote(note);
|
|
||||||
}
|
|
||||||
setShowBacklinks(false);
|
|
||||||
setShowVersions(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex h-[calc(100vh-8rem)] -m-4 md:-m-6">
|
|
||||||
{/* Left pane - note list */}
|
|
||||||
<div className="w-72 border-r flex flex-col shrink-0">
|
|
||||||
<div className="p-3 border-b">
|
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input placeholder="Search notes..." value={search} onChange={(e) => setSearch(e.target.value)} className="pl-8" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-2">
|
|
||||||
<Button size="sm" className="w-full" onClick={() => createMutation.mutate()} aria-label="New note">
|
|
||||||
<Plus className="h-4 w-4 mr-2" />New Note
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">Loading...</div>
|
|
||||||
) : notes.length === 0 ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">No notes yet.</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-0.5 p-2">
|
|
||||||
{notes.map((note) => (
|
|
||||||
<button
|
|
||||||
key={note.id}
|
|
||||||
onClick={() => selectNote(note)}
|
|
||||||
className={cn(
|
|
||||||
"w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
|
|
||||||
selectedNote?.id === note.id ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{note.isPinned && <Pin className="h-3 w-3 shrink-0 text-muted-foreground" />}
|
|
||||||
<span className="truncate font-medium">{note.title}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground mt-0.5">
|
|
||||||
{new Date(note.updatedAt).toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right pane - editor */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
{selectedNote ? (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<NoteTitleInput key={selectedNote.id} noteId={selectedNote.id} initialTitle={selectedNote.title} />
|
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowBacklinks(!showBacklinks)} aria-label="Backlinks">
|
|
||||||
<LinkIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowVersions(!showVersions)} aria-label="Version history">
|
|
||||||
<History className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" aria-label="Delete note">
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Delete Note</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>Are you sure you want to delete "{selectedNote.title}"?</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={() => deleteMutation.mutate(selectedNote.id)} className="bg-destructive text-destructive-foreground">Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 overflow-auto">
|
|
||||||
<NoteEditor key={selectedNote?.id || 'none'} initialContent={selectedNote?.content || ''} onSave={(html) => { if (selectedNote) { updateMutation.mutate({ id: selectedNote.id, data: { content: html } }); } }} />
|
|
||||||
</div>
|
|
||||||
{/* Backlinks section */}
|
|
||||||
{showBacklinks && selectedNote.backlinks && selectedNote.backlinks.length > 0 && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Linked from</h4>
|
|
||||||
<div className="space-y-1">
|
|
||||||
{selectedNote.backlinks.map((bl) => (
|
|
||||||
<div key={bl.noteId} className="text-sm text-muted-foreground hover:text-foreground cursor-pointer">
|
|
||||||
{bl.noteTitle}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Version history */}
|
|
||||||
{showVersions && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Version History</h4>
|
|
||||||
<p className="text-xs text-muted-foreground">Version history available via API.</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center flex-1 text-muted-foreground">
|
|
||||||
<div className="text-center">
|
|
||||||
<FileText className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
||||||
<p>Select a note or create a new one</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}'''
|
|
||||||
|
|
||||||
new = '''function NotesPage() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const [selectedNoteId, setSelectedNoteId] = useState<string | null>(null);
|
|
||||||
const [showBacklinks, setShowBacklinks] = useState(false);
|
|
||||||
const [showVersions, setShowVersions] = useState(false);
|
|
||||||
const selectedNoteRef = useRef<Note | null>(null);
|
|
||||||
|
|
||||||
useRealtime({ enabled: true });
|
|
||||||
|
|
||||||
const { data: notesData, isLoading } = useApiQuery<PaginatedResponse<Note>>(
|
|
||||||
["notes", search],
|
|
||||||
"/notes?limit=200" + (search ? "&search=" + encodeURIComponent(search) : "")
|
|
||||||
);
|
|
||||||
|
|
||||||
const notes = notesData?.items || [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
|
||||||
mutationFn: () => api.post<Note>("/notes", { title: "Untitled", content: "" }),
|
|
||||||
onSuccess: (note) => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
|
||||||
mutationFn: ({ id, data }: { id: string; data: any }) => api.patch<Note>("/notes/" + id, data),
|
|
||||||
onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["notes"] }); },
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: (id: string) => api.delete("/notes/" + id),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["notes"] });
|
|
||||||
selectedNoteRef.current = null;
|
|
||||||
setSelectedNoteId(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectNote = async (note: Note) => {
|
|
||||||
try {
|
|
||||||
const detail = await api.get<Note>("/notes/" + note.id);
|
|
||||||
selectedNoteRef.current = detail;
|
|
||||||
} catch {
|
|
||||||
selectedNoteRef.current = note;
|
|
||||||
}
|
|
||||||
setSelectedNoteId(note.id);
|
|
||||||
setShowBacklinks(false);
|
|
||||||
setShowVersions(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedNote = selectedNoteRef.current;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex h-[calc(100vh-8rem)] -m-4 md:-m-6">
|
|
||||||
{/* Left pane - note list */}
|
|
||||||
<div className="w-72 border-r flex flex-col shrink-0">
|
|
||||||
<div className="p-3 border-b">
|
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input placeholder="Search notes..." value={search} onChange={(e) => setSearch(e.target.value)} className="pl-8" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-2">
|
|
||||||
<Button size="sm" className="w-full" onClick={() => createMutation.mutate()} aria-label="New note">
|
|
||||||
<Plus className="h-4 w-4 mr-2" />New Note
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<ScrollArea className="flex-1">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">Loading...</div>
|
|
||||||
) : notes.length === 0 ? (
|
|
||||||
<div className="p-4 text-sm text-muted-foreground">No notes yet.</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-0.5 p-2">
|
|
||||||
{notes.map((note) => (
|
|
||||||
<button
|
|
||||||
key={note.id}
|
|
||||||
onClick={() => selectNote(note)}
|
|
||||||
className={cn(
|
|
||||||
"w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
|
|
||||||
selectedNoteId === note.id ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{note.isPinned && <Pin className="h-3 w-3 shrink-0 text-muted-foreground" />}
|
|
||||||
<span className="truncate font-medium">{note.title}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground mt-0.5">
|
|
||||||
{new Date(note.updatedAt).toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right pane - editor */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
{selectedNote ? (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 p-3 border-b">
|
|
||||||
<NoteTitleInput key={selectedNote.id} noteId={selectedNote.id} initialTitle={selectedNote.title} />
|
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowBacklinks(!showBacklinks)} aria-label="Backlinks">
|
|
||||||
<LinkIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setShowVersions(!showVersions)} aria-label="Version history">
|
|
||||||
<History className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 text-destructive" aria-label="Delete note">
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>Delete Note</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>Are you sure you want to delete "{selectedNote.title}"?</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={() => deleteMutation.mutate(selectedNote.id)} className="bg-destructive text-destructive-foreground">Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 overflow-auto">
|
|
||||||
<NoteEditor key={selectedNote.id} initialContent={selectedNote.content || ''} onSave={(html) => { if (selectedNoteRef.current) { updateMutation.mutate({ id: selectedNoteRef.current.id, data: { content: html } }); } }} />
|
|
||||||
</div>
|
|
||||||
{/* Backlinks section */}
|
|
||||||
{showBacklinks && selectedNote.backlinks && selectedNote.backlinks.length > 0 && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Linked from</h4>
|
|
||||||
<div className="space-y-1">
|
|
||||||
{selectedNote.backlinks.map((bl) => (
|
|
||||||
<div key={bl.noteId} className="text-sm text-muted-foreground hover:text-foreground cursor-pointer">
|
|
||||||
{bl.noteTitle}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Version history */}
|
|
||||||
{showVersions && (
|
|
||||||
<div className="border-t p-3">
|
|
||||||
<h4 className="text-sm font-semibold mb-2">Version History</h4>
|
|
||||||
<p className="text-xs text-muted-foreground">Version history available via API.</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center justify-center flex-1 text-muted-foreground">
|
|
||||||
<div className="text-center">
|
|
||||||
<FileText className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
||||||
<p>Select a note or create a new one</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}'''
|
|
||||||
|
|
||||||
content = content.replace(old, new, 1)
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'w') as f:
|
|
||||||
f.write(content)
|
|
||||||
print('Done')
|
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user