From 8f0935acd66923801964c24729920d551161575c Mon Sep 17 00:00:00 2001 From: Muhammed-Rahif Date: Sun, 29 Sep 2024 23:27:22 +0530 Subject: [PATCH] feat(editor): open text files from local --- src/lib/components/EditorTitle.svelte | 1 - src/lib/components/MenuBar.svelte | 9 +++++---- src/lib/components/Shortcuts.svelte | 10 ++++++++- src/lib/helpers/notepad-helper.ts | 29 ++++++++++++++++++--------- src/lib/store/store.ts | 2 +- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/lib/components/EditorTitle.svelte b/src/lib/components/EditorTitle.svelte index 18db75a..ec9ccc7 100644 --- a/src/lib/components/EditorTitle.svelte +++ b/src/lib/components/EditorTitle.svelte @@ -60,5 +60,4 @@ maxlength={24} {readonly} /> - .txt diff --git a/src/lib/components/MenuBar.svelte b/src/lib/components/MenuBar.svelte index 6de89e7..62900c9 100644 --- a/src/lib/components/MenuBar.svelte +++ b/src/lib/components/MenuBar.svelte @@ -5,6 +5,7 @@ import { editors } from '@/store/store'; import { fade } from 'svelte/transition'; import { NotepadHelper } from '@/helpers/notepad-helper'; + import { isTauri } from '$lib'; interface MenuItems { label: string; @@ -24,10 +25,10 @@ items: [ { label: 'New', - shortcut: 'Ctrl+Alt+N', - onClick: NotepadHelper.openFile + shortcut: isTauri ? 'Ctrl+N' : 'Ctrl+Alt+N', + onClick: NotepadHelper.createNew }, - { label: 'Open...', shortcut: 'Ctrl+O' }, + { label: 'Open...', shortcut: 'Ctrl+O', onClick: NotepadHelper.openFile }, { label: 'Save', shortcut: 'Ctrl+S' }, { label: 'Save as...' }, { type: 'separator' }, @@ -113,7 +114,7 @@ {#if !isXS && !tabsMode}
diff --git a/src/lib/components/Shortcuts.svelte b/src/lib/components/Shortcuts.svelte index 227f408..c279b2d 100644 --- a/src/lib/components/Shortcuts.svelte +++ b/src/lib/components/Shortcuts.svelte @@ -1,4 +1,5 @@