From 4ac7b6e9e868e7a97ddeb4bbb91b162365352ea2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 4 Jul 2025 17:17:39 +0300 Subject: [PATCH] feat(views/table): allow creation of new notes --- .../table_view/relation_editor.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts b/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts index fdc483b26..c6049026a 100644 --- a/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts +++ b/apps/client/src/widgets/view_widgets/table_view/relation_editor.ts @@ -24,18 +24,20 @@ export function RelationEditor(cell: CellComponent, onRendered, success, cancel, //set focus on the select box when the editor is selected onRendered(function(){ - note_autocomplete.initNoteAutocomplete($editor); + note_autocomplete.initNoteAutocomplete($editor, { + allowCreatingNotes: true + }).on("autocomplete:noteselected", (event, suggestion, dataset) => { + const notePath = suggestion.notePath; + if (!notePath) { + return; + } + + const noteId = notePath.split("/").at(-1); + success(noteId); + }); editor.focus(); }); - //when the value has been set, trigger the cell to update - function successFunc(){ - success($editor.getSelectedNoteId()); - } - - editor.addEventListener("change", successFunc); - editor.addEventListener("blur", successFunc); - //return the editor element return editor; };