From 788ad2ecf1c9089b8b5c9aaf801988a86e7beab2 Mon Sep 17 00:00:00 2001 From: RyotaUshio Date: Tue, 30 Apr 2024 17:05:09 +0900 Subject: [PATCH] release: 0.1.2 --- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/modals.ts | 50 +++++++++++++++++++++++------------------------ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/manifest.json b/manifest.json index 7b5b965..3eb41e9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "better-note-composer", "name": "Better Note Composer", - "version": "0.1.1", + "version": "0.1.2", "minAppVersion": "1.3.5", "description": "", "author": "Ryota Ushio", diff --git a/package-lock.json b/package-lock.json index 5700183..c7ce189 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-better-note-composer", - "version": "0.1.1", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-better-note-composer", - "version": "0.1.1", + "version": "0.1.2", "license": "MIT", "devDependencies": { "@types/node": "^16.18.96", diff --git a/package.json b/package.json index f68544d..02778b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-better-note-composer", - "version": "0.1.1", + "version": "0.1.2", "description": "An Obsidian.md plugin", "scripts": { "dev": "node esbuild.config.mjs", diff --git a/src/modals.ts b/src/modals.ts index cdc62d9..7c13ea3 100644 --- a/src/modals.ts +++ b/src/modals.ts @@ -1,5 +1,5 @@ import BetterNoteComposerPlugin from 'main'; -import { FuzzySuggestModal, Notice, Platform, TFile } from 'obsidian'; +import { FuzzySuggestModal, Keymap, Notice, Platform, TFile } from 'obsidian'; import { createFileIfNotExist } from 'utils'; @@ -35,35 +35,35 @@ export class MarkdownFileChooserModal extends FuzzySuggestModal { // @ts-ignore this.scope.register(null, 'Enter', (evt) => { if (!evt.isComposing) { + if (Keymap.isModifier(evt, 'Shift')) { + let path = this.inputEl.value; + + if (path.includes('.')) { + const extension = path.split('.').last(); + if (extension && extension !== 'md') { + new Notice(`${this.plugin.manifest.name}: Non-markdown file is not allowed`); + return; + } + } + + if (!path.endsWith('.md')) { + path += '.md'; + } + + createFileIfNotExist(this.app, path, '') + .then((file) => { + if (file) this.onSubmit(file, evt); + }); + this.close(); + + return false; + } + // @ts-ignore this.chooser.useSelectedItem(evt); return false; } }); - - this.scope.register(['Shift'], 'Enter', (evt) => { - let path = this.inputEl.value; - - if (path.includes('.')) { - const extension = path.split('.').last(); - if (extension && extension !== 'md') { - new Notice(`${this.plugin.manifest.name}: Non-markdown file is not allowed`); - return; - } - } - - if (!path.endsWith('.md')) { - path += '.md'; - } - - createFileIfNotExist(this.app, path, '') - .then((file) => { - if (file) this.onSubmit(file, evt); - }); - this.close(); - - return false; - }); } get settings() {