Fix dragging of files to the filesystem on macOS (and maybe Linux)

Calling getTransferData('zotero/item') when handling the
application/x-moz-file-promise seems to have stopped working between Fx46 and
Fx47, though I can't get older Nightly builds to run with mozregression
(Sierra?) to find the specific change. Instead, work around this by passing an
array of item ids to the file drag data provider.
This commit is contained in:
Dan Stillman 2016-09-30 02:42:17 -04:00
parent e0b96a873b
commit db8d3fd4b4

View file

@ -2612,7 +2612,7 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) {
Zotero.debug("Adding file via x-moz-file-promise");
event.dataTransfer.mozSetDataAt(
"application/x-moz-file-promise",
new Zotero.ItemTreeView.fileDragDataProvider(),
new Zotero.ItemTreeView.fileDragDataProvider(itemIDs),
0
);
break;
@ -2688,7 +2688,9 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) {
// Implements nsIFlavorDataProvider for dragging attachment files to OS
//
// Not used on Windows in Firefox 3 or higher
Zotero.ItemTreeView.fileDragDataProvider = function() { };
Zotero.ItemTreeView.fileDragDataProvider = function (itemIDs) {
this._itemIDs = itemIDs;
};
Zotero.ItemTreeView.fileDragDataProvider.prototype = {
QueryInterface : function(iid) {
@ -2712,13 +2714,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
transferable.getTransferData("application/x-moz-file-promise-dir", dirPrimitive, dataSize);
var destDir = dirPrimitive.value.QueryInterface(Components.interfaces.nsILocalFile);
// Get the items we're dragging
var items = {};
transferable.getTransferData("zotero/item", items, dataSize);
items.value.QueryInterface(Components.interfaces.nsISupportsString);
var draggedItems = Zotero.Items.get(items.value.data.split(','));
var draggedItems = Zotero.Items.get(this._itemIDs);
var items = [];
// Make sure files exist