Skip to content
Merged
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
19 changes: 19 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
33 changes: 33 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
const numberPlugin = ViewPlugin.fromClass(
class {
decorations
constructor(view: any) {

Check warning on line 62 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build-and-test (windows-latest)

Unexpected any. Specify a different type

Check warning on line 62 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build-and-test (ubuntu-latest)

Unexpected any. Specify a different type
this.decorations = numberMatcher.createDeco(view)
}
update(update: any) {
Expand Down Expand Up @@ -450,6 +450,26 @@
}
}

// 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) {
Expand Down Expand Up @@ -707,6 +727,12 @@
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(() => {
Expand All @@ -723,6 +749,13 @@
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()
Expand Down
Loading