From 20173d544b2fbb04b05007510953e8bec776dfea Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 17 Jun 2025 20:41:23 +0800 Subject: [PATCH 1/2] feat(autocomple): support specifying path when creating a new note --- apps/client/src/services/note_autocomplete.ts | 6 ++-- apps/client/src/services/note_create.ts | 4 +-- .../src/translations/en/translation.json | 2 ++ .../src/widgets/dialogs/note_type_chooser.ts | 32 +++++++++++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.ts index 4ffff8594..d6eb4df0e 100644 --- a/apps/client/src/services/note_autocomplete.ts +++ b/apps/client/src/services/note_autocomplete.ts @@ -289,13 +289,11 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { } if (suggestion.action === "create-note") { - const { success, noteType, templateNoteId } = await noteCreateService.chooseNoteType(); - + const { success, noteType, templateNoteId, notePath } = await noteCreateService.chooseNoteType(); if (!success) { return; } - - const { note } = await noteCreateService.createNote(suggestion.parentNoteId, { + const { note } = await noteCreateService.createNote( notePath || suggestion.parentNoteId, { title: suggestion.noteTitle, activate: false, type: noteType, diff --git a/apps/client/src/services/note_create.ts b/apps/client/src/services/note_create.ts index 5fa262553..6ce92bc0d 100644 --- a/apps/client/src/services/note_create.ts +++ b/apps/client/src/services/note_create.ts @@ -116,7 +116,7 @@ async function chooseNoteType() { } async function createNoteWithTypePrompt(parentNotePath: string, options: CreateNoteOpts = {}) { - const { success, noteType, templateNoteId } = await chooseNoteType(); + const { success, noteType, templateNoteId, notePath } = await chooseNoteType(); if (!success) { return; @@ -125,7 +125,7 @@ async function createNoteWithTypePrompt(parentNotePath: string, options: CreateN options.type = noteType; options.templateNoteId = templateNoteId; - return await createNote(parentNotePath, options); + return await createNote(notePath || parentNotePath, options); } /* If the first element is heading, parse it out and use it as a new heading. */ diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index ab7933617..1e9db9fe4 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -233,6 +233,8 @@ "move_success_message": "Selected notes have been moved into " }, "note_type_chooser": { + "select_path_prompt": "Select where to create the new note:", + "search_placeholder":"Search path by name (auto if empty)", "modal_title": "Choose note type", "close": "Close", "modal_body": "Choose note type / template of the new note:", diff --git a/apps/client/src/widgets/dialogs/note_type_chooser.ts b/apps/client/src/widgets/dialogs/note_type_chooser.ts index ff4442826..3356e4c5e 100644 --- a/apps/client/src/widgets/dialogs/note_type_chooser.ts +++ b/apps/client/src/widgets/dialogs/note_type_chooser.ts @@ -2,6 +2,7 @@ import type { CommandNames } from "../../components/app_context.js"; import type { MenuCommandItem } from "../../menus/context_menu.js"; import { t } from "../../services/i18n.js"; import noteTypesService from "../../services/note_types.js"; +import noteAutocompleteService from "../../services/note_autocomplete.js"; import BasicWidget from "../basic_widget.js"; import { Dropdown, Modal } from "bootstrap"; @@ -13,6 +14,11 @@ const TPL = /*html*/` z-index: 1100 !important; } + .note-type-chooser-dialog .input-group { + margin-top: 15px; + margin-bottom: 15px; + } + .note-type-chooser-dialog .note-type-dropdown { position: relative; font-size: large; @@ -30,6 +36,12 @@ const TPL = /*html*/`