From d1992b061c5884ac743e8d1c2cddfab5ae4060df Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 2 Sep 2019 21:58:03 +0200 Subject: [PATCH] fix drag & drop for chrome and code editor --- src/public/javascripts/services/drag_and_drop.js | 4 +++- src/public/javascripts/services/note_detail.js | 7 ++++--- src/public/javascripts/services/note_detail_code.js | 3 ++- src/public/javascripts/services/tab_context.js | 4 ---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/public/javascripts/services/drag_and_drop.js b/src/public/javascripts/services/drag_and_drop.js index 19c354c55..0253f8dbf 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.js index 66b898cea..2af5a19f7 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.js index 30b6dc0c8..243b17a32 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.js index 7b2c29e6f..4dc65af65 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() {