Skip to content

Commit

Permalink
fix: shortcuts in reader
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Oct 27, 2023
1 parent d060bfc commit d2726a1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/modules/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,23 @@ async function triggerShortcut(e: KeyboardEvent) {
const shortcut = new KeyModifier(addon.data.shortcut.getRaw());
addon.data.shortcut = undefined;

const items = Zotero.getActiveZoteroPane().getSelectedItems();
if (items.length === 0) {
await addon.api.actionManager.dispatchActionByShortcut(shortcut, {
itemID: -1,
});
return;
let items = [] as Zotero.Item[];
switch (Zotero_Tabs.selectedType) {
case "library": {
items = Zotero.getActiveZoteroPane().getSelectedItems();
break;
}
case "reader": {
const reader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID);
if (reader) {
items = [reader._item];
}
break;
}
}
// Trigger action for multiple items
await addon.api.actionManager.dispatchActionByShortcut(shortcut, {
itemIDs: items.map((item) => item.id),
itemIDs: items.map((item) => item?.id),
});
// Trigger action for each item
for (const item of items) {
Expand Down

0 comments on commit d2726a1

Please sign in to comment.