Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix drag & drop for chrome and code editor
zadamd1992b061c58
diff --git a/src/public/javascripts/services/drag_and_drop.js b/src/public/javascripts/services/drag_and_drop.jsindex 19c354c552..0253f8dbf1 100644--- a/src/public/javascripts/services/drag_and_drop.js+++ b/src/public/javascripts/services/drag_and_drop.js@@ -28,9 +28,11 @@ const dragAndDropSetup = {const dataTransfer = data.dataTransfer;if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {+ const files = [...dataTransfer.files]; // chrome has issue that dataTransfer.files empties after async operation+const importDialog = await import('../dialogs/import.js');- importDialog.uploadFiles(node.data.noteId, dataTransfer.files, {+ importDialog.uploadFiles(node.data.noteId, files, {safeImport: true,shrinkImages: true,textImportedAsText: true,diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.jsindex 66b898ceab..2af5a19f78 100644--- a/src/public/javascripts/services/note_detail.js+++ b/src/public/javascripts/services/note_detail.js@@ -389,8 +389,11 @@ $tabContentsContainer.on("drop", async e => {return;}+ const files = [...e.originalEvent.dataTransfer.files]; // chrome has issue that dataTransfer.files empties after async operation+const importDialog = await import("../dialogs/import.js");- importDialog.uploadFiles(activeNote.noteId, e.originalEvent.dataTransfer.files, {++ importDialog.uploadFiles(activeNote.noteId, files, {safeImport: true,shrinkImages: true,textImportedAsText: true,@@ -416,8 +419,6 @@ tabRow.addListener('activeTabChange', async ({ detail }) => {const tabId = detail.tabEl.getAttribute('data-tab-id');await showTab(tabId);-- console.log(`Activated tab ${tabId}`);});tabRow.addListener('tabRemove', async ({ detail }) => {diff --git a/src/public/javascripts/services/note_detail_code.js b/src/public/javascripts/services/note_detail_code.jsindex 30b6dc0c8d..243b17a32e 100644--- a/src/public/javascripts/services/note_detail_code.js+++ b/src/public/javascripts/services/note_detail_code.js@@ -48,7 +48,8 @@ class NoteDetailCode {tabindex: 100,// we linewrap partly also because without it horizontal scrollbar displays only when you scroll// all the way to the bottom of the note. With line wrap there's no horizontal scrollbar so no problem- lineWrapping: true+ lineWrapping: true,+ dragDrop: false // with true the editor inlines dropped files which is not what we expect});this.onNoteChange(() => this.ctx.noteChanged());diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.jsindex 7b2c29e6f9..4dc65af650 100644--- a/src/public/javascripts/services/tab_context.js+++ b/src/public/javascripts/services/tab_context.js@@ -101,8 +101,6 @@ class TabContext {this.$unprotectButton = this.$tabContent.find(".unprotect-button");this.$unprotectButton.click(protectedSessionService.unprotectNoteAndSendToServer);-- console.debug(`Created note tab ${this.tabId}`);}async setNote(note, notePath) {@@ -139,8 +137,6 @@ class TabContext {if (this.sidebar) {this.sidebar.noteLoaded(); // load async}-- console.debug(`Switched tab ${this.tabId} to ${this.noteId}`);}show() {