Make item pane attachments/notes/related item rows draggable (#5184)

This commit is contained in:
Abe Jellinek 2025-04-04 12:27:02 -04:00 • committed by GitHub
parent 3d538d71ca
commit e6f1983073
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 1 deletions

View file

@ -82,6 +82,7 @@ import { getCSSItemTypeIcon } from 'components/icons';
this._removeButton = this.querySelector('.zotero-clicky-minus');
this._attachmentButton.addEventListener('click', this._handleAttachmentClick);
this._attachmentButton.addEventListener('dragstart', this._handleAttachmentDragStart);
this._annotationButton.addEventListener('click', this._handleAnnotationClick);
if (this.editable) {
@ -100,6 +101,10 @@ import { getCSSItemTypeIcon } from 'components/icons';
ZoteroPane.viewAttachment(this._attachment.id, event);
};
_handleAttachmentDragStart = (event) => {
Zotero.Utilities.Internal.onDragItems(event, [this._attachment.id]);
};
_handleAnnotationClick = () => {
// TODO: jump to annotations pane
let pane;

View file

@ -118,6 +118,10 @@ import { getCSSItemTypeIcon } from 'components/icons';
row.append(remove);
}
row.addEventListener('dragstart', (event) => {
Zotero.Utilities.Internal.onDragItems(event, [id]);
});
body.append(row);
}

View file

@ -144,6 +144,10 @@ import { getCSSItemTypeIcon } from 'components/icons';
row.append(remove);
}
row.addEventListener('dragstart', (event) => {
Zotero.Utilities.Internal.onDragItems(event, [id]);
});
body.append(row);
}
this._updateCount();

View file

@ -3289,7 +3289,12 @@ Zotero.Utilities.Internal.OpenURL = {
},
};
Zotero.Utilities.Internal.onDragItems = function (event, itemIDs, dragImage) {
/**
* @param {DragEvent} event
* @param {number[]} itemIDs
* @param {Element} [dragImage]
*/
Zotero.Utilities.Internal.onDragItems = function (event, itemIDs, dragImage = event.currentTarget) {
// See note in LibraryTreeView::setDropEffect()
if (Zotero.isWin || Zotero.isLinux) {
event.dataTransfer.effectAllowed = 'copyMove';