From d723065a3d8705c3d8e336efbdb4a9424c93ecff Mon Sep 17 00:00:00 2001 From: Dan Stillman <dstillman@zotero.org> Date: Mon, 30 Aug 2021 02:39:27 -0400 Subject: [PATCH] HTML tree: Don't move dragged external files by default on macOS Fixes #2172 --- chrome/content/zotero/collectionTree.jsx | 17 ++++++++++++++++- chrome/content/zotero/itemTree.jsx | 19 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/collectionTree.jsx b/chrome/content/zotero/collectionTree.jsx index 62c2bfcc97..9f6f2292eb 100644 --- a/chrome/content/zotero/collectionTree.jsx +++ b/chrome/content/zotero/collectionTree.jsx @@ -1936,6 +1936,21 @@ var CollectionTree = class CollectionTree extends LibraryTree { } } else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') { + // See note in onDragOver() above + if (dataType == 'application/x-moz-file' && Zotero.isMac) { + if (event.metaKey) { + if (event.altKey) { + dropEffect = 'link'; + } + else { + dropEffect = 'move'; + } + } + else { + dropEffect = 'copy'; + } + } + var targetLibraryID = targetTreeRow.ref.libraryID; if (targetTreeRow.isCollection()) { var parentCollectionID = targetTreeRow.ref.id; @@ -1974,7 +1989,7 @@ var CollectionTree = class CollectionTree extends LibraryTree { collections: parentCollectionID ? [parentCollectionID] : undefined }); // If moving, delete original file - if (dragData.dropEffect == 'move') { + if (dropEffect == 'move') { try { file.remove(false); } diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 6a8aa185a7..0202218a00 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -2359,7 +2359,22 @@ var ItemTree = class ItemTree extends LibraryTree { window.ZoteroPane.displayCannotEditLibraryMessage(); return; } - + + // See note in onDragOver() above + if (dataType == 'application/x-moz-file' && Zotero.isMac) { + if (event.metaKey) { + if (event.altKey) { + dropEffect = 'link'; + } + else { + dropEffect = 'move'; + } + } + else { + dropEffect = 'copy'; + } + } + var targetLibraryID = collectionTreeRow.ref.libraryID; var parentItemID = false; @@ -2484,7 +2499,7 @@ var ItemTree = class ItemTree extends LibraryTree { } }); // If moving, delete original file - if (dragData.dropEffect == 'move') { + if (dropEffect == 'move') { try { await OS.File.remove(file); }