Skip to content

Commit cf3fda1

Browse files
committed
Add font & settings. add some features.
1 parent 70692ec commit cf3fda1

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

src/main/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function createWindow(): void {
4848
// Some APIs can only be used after this event occurs.
4949
app.whenReady().then(async () => {
5050
// Set app user model id for windows
51-
electronApp.setAppUserModelId('com.electron')
51+
electronApp.setAppUserModelId('me.saino.leavepad')
5252

5353
const userDir = app.getPath('userData')
5454
const defaultData: Note[] = []

src/renderer/src/App.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
import { getTime } from 'date-fns'
4141
import { Trans, useTranslation } from 'react-i18next'
4242
import i18n from './i18n/configs'
43-
import { Drawer, DrawerClose, DrawerContent, DrawerTrigger } from './components/ui/drawer'
43+
import { Drawer, DrawerContent, DrawerTrigger } from './components/ui/drawer'
4444
import LogoImg from './assets/leavepad_logo.svg'
4545

4646
initializeNoteEditor()
@@ -64,6 +64,7 @@ function App(): JSX.Element {
6464
const [globalSettingsOpen, setGlobalSettingsOpen] = useState(false)
6565
const [currentSearchValue, setCurrentSearchValue] = useState('')
6666
const [isSidebarOpen, setSidebarOpen] = useState(true)
67+
const [isDrawerOpen, setDrawerOpen] = useState(false)
6768

6869
const sortNotes = (unsortedNotes: Note[]) => {
6970
const sortBy = currentNoteEditorSettings.sortBy
@@ -146,6 +147,10 @@ function App(): JSX.Element {
146147
const onNoteCardClick = (note: Note) => {
147148
setCurrentNote(note)
148149

150+
if (isDrawerOpen === true) {
151+
setDrawerOpen(false)
152+
}
153+
149154
const noteTab = noteTabs.find((tab) => tab.id === note.id)
150155
// Focus exists tab.
151156
if (noteTab) {
@@ -154,10 +159,6 @@ function App(): JSX.Element {
154159

155160
// Add tab when not included noteTabs.
156161
setNoteTabs([...noteTabs, { id: note.id, name: note.name }])
157-
158-
if (editorRef.current != null) {
159-
editorRef.current.focus()
160-
}
161162
}
162163

163164
const onNoteCardSetName = async (changedNote: Note, title: string) => {
@@ -312,7 +313,7 @@ function App(): JSX.Element {
312313
</div>
313314
</ScrollArea>
314315
) : (
315-
<Drawer direction="left">
316+
<Drawer direction="left" open={isDrawerOpen} onOpenChange={setDrawerOpen}>
316317
<DrawerTrigger asChild>
317318
<Button>
318319
<div className="codicon codicon-note"></div>
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@font-face {
2+
font-family: 'HackGen';
3+
src: url('./HackGen/HackGen-Regular.ttf') format('truetype');
4+
font-weight: normal;
5+
}

src/renderer/src/assets/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@import './fonts/geist-mono.css';
33
@import './fonts/noto-sans.css';
44
@import './fonts/noto-color-emoji.css';
5+
@import './fonts/hackgen.css';
56
@import '../../../../node_modules/@vscode/codicons/dist/codicon.css';
67

78
@tailwind base;

src/renderer/src/components/note-editor.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function NoteEditor(
5454
): JSX.Element {
5555
const [settings] = useAtom(currentNoteEditorSettingsAtom)
5656

57-
const handleEditorDidMount = (editor, _monaco) => {
57+
const handleEditorDidMount = (monacoEditor, _monaco) => {
5858
if (ref == null) {
5959
return
6060
}
@@ -63,14 +63,18 @@ function NoteEditor(
6363
}
6464
// here is the editor instance
6565
// you can store it in `useRef` for further usage
66-
ref.current = editor
66+
ref.current = monacoEditor
6767

6868
if (ref.current != null) {
6969
ref.current.onDidChangeCursorPosition(onDidChangeCursorPosition)
7070

7171
// for DEBUG
7272
// @ts-ignore
73-
window.editor = editor
73+
window.editor = monacoEditor
74+
// @ts-ignore
75+
window.monaco = monaco
76+
77+
monaco.editor.remeasureFonts()
7478
}
7579
}
7680

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const defaultNoteEditorSettings: NoteEditorSettings = {
5858
useTabStops: false,
5959
wordWrap: 'off',
6060
fontFamily:
61-
"Consolas, Menlo, Monaco, 'Courier New', 'Droid Sans Mono', 'monospace', monospace, 'Noto Sans JP', 'Noto Color Emoji'"
61+
"HackGen, Consolas, Menlo, Monaco, 'Courier New', 'Droid Sans Mono', 'monospace', monospace, 'Noto Sans JP', 'Noto Color Emoji'"
6262
}
6363
}
6464

0 commit comments

Comments
 (0)