Skip to content

Build your personal knowledge base with Trilium Notes

Merge branch 'stable'

azivner6b9ff47c88c9
diff --cc src/public/javascripts/init.js
index ac32d3d732,07286ec341..c2700afdad
--- a/src/public/javascripts/init.js
+++ b/src/public/javascripts/init.js
@@@ -207,30 -207,10 +207,32 @@@ if (isElectron())
await noteTree.activateNode(parentNoteId);
- const node = noteTree.getCurrentNode();
+ setTimeout(() => {
+ const node = noteTree.getCurrentNode();
- await noteTree.createNote(node, node.data.noteId, 'into', node.data.isProtected);
+ noteTree.createNote(node, node.data.noteId, 'into', node.data.isProtected);
+ }, 500);
});
-}
+}
+
+function uploadAttachment() {
+ $("#file-upload").trigger('click');
+}
+
+$("#file-upload").change(async function() {
+ const formData = new FormData();
+ formData.append('upload', this.files[0]);
+
+ const resp = await $.ajax({
+ url: baseApiUrl + 'attachments/upload/' + noteEditor.getCurrentNoteId(),
+ headers: server.getHeaders(),
+ data: formData,
+ type: 'POST',
+ contentType: false, // NEEDED, DON'T OMIT THIS
+ processData: false, // NEEDED, DON'T OMIT THIS
+ });
+
+ await noteTree.reload();
+
+ await noteTree.activateNode(resp.noteId);
+});