Skip to content

Build your personal knowledge base with Trilium Notes

feat(views/table): allow creation of new notes

Elian Doran4ac7b6e9e868
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 fdc483b260..c6049026a2 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;
};