Fixed drag/drop

This commit is contained in:
WBHarry 2026-03-12 22:12:45 +01:00
parent 5c8d16e100
commit ee3bbaec53

View file

@ -74,6 +74,15 @@ export default function DHApplicationMixin(Base) {
class DHSheetV2 extends HandlebarsApplicationMixin(Base) { class DHSheetV2 extends HandlebarsApplicationMixin(Base) {
#nonHeaderAttribution = ['environment', 'ancestry', 'community', 'domainCard']; #nonHeaderAttribution = ['environment', 'ancestry', 'community', 'domainCard'];
/**
* @param {DHSheetV2Configuration} [options={}]
*/
constructor(options = {}) {
super(options);
this._setupDragDrop();
}
/** /**
* The default options for the sheet. * The default options for the sheet.
* @type {DHSheetV2Configuration} * @type {DHSheetV2Configuration}
@ -165,7 +174,9 @@ export default function DHApplicationMixin(Base) {
/**@inheritdoc */ /**@inheritdoc */
_attachPartListeners(partId, htmlElement, options) { _attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options); super._attachPartListeners(partId, htmlElement, options);
// this._dragDrop.forEach(d => d.bind(htmlElement));
/* Core dragDrop from ActorDocument is always only 1. Possible we could refactor our own */
if (Array.isArray(this._dragDrop)) this._dragDrop.forEach(d => d.bind(htmlElement));
// Handle delta inputs // Handle delta inputs
for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) { for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) {
@ -338,6 +349,26 @@ export default function DHApplicationMixin(Base) {
/* Drag and Drop */ /* Drag and Drop */
/* -------------------------------------------- */ /* -------------------------------------------- */
/**
* Creates drag-drop handlers from the configured options.
* @returns {foundry.applications.ux.DragDrop[]}
* @private
*/
_setupDragDrop() {
if (this._dragDrop) {
this._dragDrop.callbacks.dragStart = this._onDragStart;
this._dragDrop.callback.drop = this._onDrop;
} else {
this._dragDrop = this.options.dragDrop.map(d => {
d.callbacks = {
dragstart: this._onDragStart.bind(this),
drop: this._onDrop.bind(this)
};
return new foundry.applications.ux.DragDrop.implementation(d);
});
}
}
/** /**
* Handle dragStart event. * Handle dragStart event.
* @param {DragEvent} event * @param {DragEvent} event