Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ npm install
npm run dev
```

## ⌨️ Keyboard Shortcuts

- **Focus search**: `Ctrl + K` / `Cmd + K` or `Ctrl + F`
- **New note**: `Ctrl + N` / `Cmd + N`


## 💡 How to Contribute

We ❤️ contributions from the community!
Expand Down
23 changes: 21 additions & 2 deletions src/components/NotesSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { PlusCircle, Search, FileDown, LogIn, LogOut } from "lucide-react";
import jsPDF from "jspdf";
import { useState } from "react";
import { useEffect, useRef, useState } from "react";

import { ScrollArea } from "@/components/ui/scroll-area";
import { ThemeToggle } from "@/components/theme/themeToggle";
import { useCurrentUser } from "@/context/CurrentUserContext";
Expand All @@ -31,6 +32,7 @@ export function NotesSidebar({
}: NotesSidebarProps) {
const [searchQuery, setSearchQuery] = useState("");
const [isAuthOpen, setIsAuthOpen] = useState(false);
const searchInputRef = useRef<HTMLInputElement>(null);

const { isLoggedIn, logout, user } = useCurrentUser(); // reactive to login/logout

Expand All @@ -52,6 +54,22 @@ export function NotesSidebar({
}
);

useEffect(() => {
const handler = (e: KeyboardEvent) => {
const meta = e.ctrlKey || e.metaKey;
if (meta && (e.key === "k" || e.key === "K" || e.key === "f" || e.key === "F")) {
e.preventDefault();
searchInputRef.current?.focus();
}
if (meta && (e.key === "n" || e.key === "N")) {
e.preventDefault();
onCreateNote();
}
};
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [onCreateNote]);

const handleAuthAction = () => {
if (isLoggedIn) {
logout(); // logout instantly
Expand Down Expand Up @@ -90,7 +108,7 @@ export function NotesSidebar({
doc.text(activeNote.title || 'Untitled Note', margin, margin);

doc.setFontSize(10);
const tagString = activeNote.tags.map(t => `${t.emoji} ${t.label}`).join(', ');
const tagString = (activeNote.tags ?? []).map(t => `${t.emoji} ${t.label}`).join(', ');
doc.text(`Tags: ${tagString}`, margin, margin + 5);

doc.setFontSize(12);
Expand Down Expand Up @@ -130,6 +148,7 @@ export function NotesSidebar({
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="pl-9"
ref={searchInputRef}
/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/types/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Note {
content: string;
createdAt: Date;
updatedAt: Date;
tags?: { emoji: string; label: string }[];
}
// Utility function to format timestamps
export const formatTimestamp = (date: Date, locale: string = 'en-US'): string => {
Expand Down