diff --git a/src/App.css b/src/App.css index 6d7db10..b0af487 100644 --- a/src/App.css +++ b/src/App.css @@ -572,6 +572,25 @@ body { border-radius: 2px; } +.cm-currency-pill { + display: inline-block; + background-color: rgba(13, 148, 136, 0.15); /* Teal */ + color: #0d9488; + padding: 0px 6px; + border-radius: 4px; + font-family: inherit; + font-weight: 500; + font-size: 0.95em; + margin: 0 2px; + border: 1px solid rgba(13, 148, 136, 0.3); +} + +.cm-currency-highlight { + color: #0d9488; + background-color: rgba(13, 148, 136, 0.1); + border-radius: 2px; +} + .cm-tag-pill { display: inline-block; background-color: rgba(59, 130, 246, 0.15); /* Blue */ diff --git a/src/App.tsx b/src/App.tsx index e2325c7..578d353 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -450,6 +450,26 @@ const hideMarkdownPlugin = ViewPlugin.fromClass( } } + // Currency Formats + const reCurrency = /[$€£¥₹]\s*\d+(?:,\d{3})*(?:\.\d{1,2})?/g + while ((match = reCurrency.exec(text)) !== null) { + const start = from + match.index + const end = start + match[0].length + if (!isCursorInMatch(start, end)) { + decos.push({ + from: start, + to: end, + deco: Decoration.mark({ class: 'cm-currency-pill' }), + }) + } else { + decos.push({ + from: start, + to: end, + deco: Decoration.mark({ class: 'cm-currency-highlight' }), + }) + } + } + // Tags (!tag) const reTag = /![a-zA-Z0-9_-]+/g while ((match = reTag.exec(text)) !== null) { @@ -707,6 +727,12 @@ function App() { currentNoteIndexRef.current = currentNoteIndex }, [currentNoteIndex]) + useEffect(() => { + if (notes.length > 0 && currentNoteIndex >= 0 && currentNoteIndex < notes.length) { + localStorage.setItem('papercache-last-open-note', notes[currentNoteIndex].id) + } + }, [currentNoteIndex, notes]) + useEffect(() => { if (showNoteSearch && searchInputRef.current) { setTimeout(() => { @@ -723,6 +749,13 @@ function App() { const loaded = await window.electronAPI.getNotes() if (loaded.length > 0) { setNotes(loaded) + const lastOpenNoteId = localStorage.getItem('papercache-last-open-note') + if (lastOpenNoteId) { + const idx = loaded.findIndex((n: Note) => n.id === lastOpenNoteId) + if (idx !== -1) { + setCurrentNoteIndex(idx) + } + } } } loadNotes()