Skip to content

Commit

Permalink
fix: drag
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny authored and MuiseDestiny committed Nov 19, 2024
1 parent 6966fa2 commit 750f7f3
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/modules/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Views {
if (!column) { return span }
span.className = `cell ${column.className}`;
const div = document.querySelector(`#item-tree-main-default-row-${index}`) as HTMLDivElement;

if (div && div.getAttribute("_dragend") != "true") {
div.addEventListener(
"dragend",
Expand All @@ -68,7 +69,10 @@ class Views {
return;
}
ztoolkit.log("_dragend", event)
addon.api.citeItems();
if (!this.getColumnInfo("citation")?.hidden) {

addon.api.citeItems();
}
},
{ passive: true },
);
Expand All @@ -91,7 +95,11 @@ class Views {
"onDragStart",
config.addonRef,
(original: any) => async (event: any, row: number) => {
event.dataTransfer.setData("text/plain", "");
if (!this.getColumnInfo("citation")?.hidden) {
event.dataTransfer.setData("text/plain", "");
} else {
original.bind(this)(event, row)
}
},
);
}
Expand Down Expand Up @@ -122,6 +130,16 @@ class Views {
/* empty */
}
}

private getColumnInfo(dataKey: string) {
try {
// @ts-ignore
const columnInfo = ZoteroPane.itemsView._columns.find((i: any) => i.dataKey.endsWith(dataKey))
return columnInfo
} catch { return {} }
}
}

export default Views;


0 comments on commit 750f7f3

Please sign in to comment.