Description
Is there an existing issue for this?
- I have searched the existing issues
Are you using the latest Zotero and the latest plugin?
- I have confirmed I'm using the latest Zotero and the latest plugin
Environment
- OS: Window 11
- Zotero Version: 7.0.13
- Plugin Version: 2.1.0
Describe the bug
I used Zotero Connector to create an email item type from Gmail. (You have to click on the print button, then cancel it to force Zotero to change the icon to an email type.) Then, I right-clicked on the item in my item list and chose "Copy Link." Nothing happens when I tried to paste the link into a freestanding note. I also tried it on the snapshot, and it was the same problem. Other item types are pasting into the note fine.
Debug Output
[JavaScript Error: "uncaught exception: undefined"]
appName => Zotero, version => 7.0.13 (x64), os => Windows 11 26100, locale => en-US, extensions => Actions and Tags for Zotero (2.1.0, extension), Add-on Market for Zotero (1.8.0, extension, disabled), Better Notes for Zotero (2.3.0, extension, disabled), Zotero OCR (0.8.1, extension, disabled)
(3)(+0087620): Viewing item
(3)(+0000000): Refreshing item box
(3)(+0000001): Setting mode to 'edit'
(3)(+0000086): Refreshing item box
(3)(+0000119): itemTree.render(). Displaying Item Tree
(4)(+0000572): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [83416, '']
(4)(+0000003): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [83416, '']
(4)(+0000003): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [83416, '']
(4)(+0000002): SELECT IA.itemID FROM itemAttachments IA NATURAL JOIN items I LEFT JOIN itemData ID ON (IA.itemID=ID.itemID AND fieldID=13) LEFT JOIN itemDataValues IDV ON (ID.valueID=IDV.valueID) WHERE parentItemID=? AND linkMode NOT IN (3) AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC [83416, '']
(4)(+0002832): Beginning DB transaction JxyzWSs5
(4)(+0000003): Committed DB transaction JxyzWSs5
(3)(+0000001): [Actions and Tags for Zotero] applyAction {"event":0,"operation":4,"data":"// @author windingwind, garth74\n// @link https://github.com/windingwind/zotero-actions-tags/discussions/115\n// @Usage Select an item in the library and press the assigned shortcut keys\n// @update Mon, 22 Jan 2024 00:10:18 GMT (by new Date().toGMTString())\n\n// EDIT THESE SETTINGS\n\n/** @type {string} Name of the field to use as the link text. To use the citation key, set this to "citationKey". /\nlet linkTextField = "title";\n\n/* @type {'html' | 'md' | 'plain'} What type of link to create. /\nlet linkType = "html";\n\n/* @type {boolean} If true, make the link specific to the currently selected collection. /\nlet useColl = false;\n\n/* @type {boolean} If true, use Better Notes zotero://note link when the selected item is a note. /\nlet useNoteLink = false;\n\n/* @type {'select' | 'open-pdf' | 'auto'} Action of link*/\nlet linkAction = "auto"; // auto = open-pdf for PDFs and annotations, select for everything else\n\n// END OF EDITABLE SETTINGS\n\n// For efficiency, only execute once for all selected items\nif (item) return;\nitem = items[0];\nif (!item && !collection) return "[Copy Zotero Link] item is empty";\n\nif (collection) {\n linkAction = "select";\n useColl = true;\n}\n\nif (linkAction === "auto") {\n if (item.isPDFAttachment() || item.isAnnotation()) {\n linkAction = "open-pdf";\n } else {\n linkAction = "select";\n }\n}\n\nconst uriParts = [];\nlet uriParams = "";\n\nlet targetItem = item;\nif (linkAction === "open-pdf") {\n uriParts.push("zotero://open-pdf");\n if (item.isRegularItem()) {\n targetItem = (await item.getBestAttachments()).find((att) =>\n att.isPDFAttachment()\n );\n } else if (item.isAnnotation()) {\n targetItem = item.parentItem;\n // If the item is an annotation, we want to open the PDF at the page of the annotation\n let pageIndex = 1;\n try {\n pageIndex = JSON.parse(item.annotationPosition).pageIndex + 1;\n } catch (e) {\n Zotero.warn(e);\n }\n uriParams = ?page=${pageIndex}&annotation=${item.key}
;\n }\n} else {\n uriParts.push("zotero://select");\n if (item?.isAnnotation()) {\n targetItem = item.parentItem;\n }\n}\n\nif (!targetItem && !collection) return "[Copy Zotero Link] item is invalid";\n\n// Get the link text using the link_text_field
argument\nlet linkText;\nif (collection) {\n // When collection
is truthy, this script was triggered in the collection menu.\n // Use collection name if this is a collection link\n linkText = collection.name;\n} else if (item.isAttachment()) {\n // Try to use top-level item for link text\n linkText = Zotero.Items.getTopLevel([item])[0].getField(linkTextField);\n} else if (item.isAnnotation()) {\n // Add the annotation text to the link text\n linkText = ${targetItem.getField(linkTextField)}(${\n item.annotationComment || item.annotationText || \"annotation\"\n })
;\n} else {\n // Use the item's field\n linkText = item.getField(linkTextField);\n}\n\n// Add the library or group URI part (collection must go first)\nlet libraryType = (collection || item).library.libraryType;\nif (libraryType === "user") {\n uriParts.push("library");\n} else {\n uriParts.push(\n groups/${Zotero.Libraries.get((collection || item).libraryID).groupID}
\n );\n}\n\n// If useColl, make the link collection specific\nif (useColl) {\n // see https://forums.zotero.org/discussion/73893/zotero-select-for-collections\n let coll = collection || Zotero.getActiveZoteroPane().getSelectedCollection();\n\n // It's possible that a collection isn't selected. When that's the case,\n // this will fall back to the typical library behavior.\n\n // If a collection is selected, add the collections URI part\n if (!!coll) uriParts.push(collections/${coll.key}
);\n}\n\nif (!collection) {\n // Add the item URI part\n uriParts.push(items/${targetItem.key}
);\n}\n\n// Join the parts together\nlet uri = uriParts.join("/");\n\n// Add the URI parameters\nif (uriParams) {\n uri += uriParams;\n}\n\nif (useNoteLink && item?.isNote() && Zotero.BetterNotes) {\n uri = Zotero.BetterNotes.api.convert.note2link(item);\n}\n\n// Format the link and copy it to the clipboard\nconst clipboard = new Zotero.ActionsTags.api.utils.ClipboardHelper();\nif (linkType == "html") {\n clipboard.addText(<a href=\"${uri}\">${linkText}</a>
, "text/unicode");\n} else if (linkType == "md") {\n clipboard.addText([${linkText}](${uri})
, "text/unicode");\n} else {\n clipboard.addText(uri, "text/unicode");\n}\n\nclipboard.addText(<a href=\"${uri}\">${linkText}</a>
, "text/html");\n\nclipboard.copy();\n\nreturn [Copy Zotero Link] link ${uri} copied.
;","shortcut":"Shift,Ctrl,Alt,I","enabled":true,"menu":"Copy Link","name":"Copy Zotero Link","showInMenu":{"item":true,"collection":true,"tools":true,"reader":true,"readerAnnotation":true}} {"itemIDs":[83416],"triggerType":"menu"}
(4)(+0000009): Beginning DB transaction Btu5oCVE
(4)(+0000005): Item 83416 has not changed
(4)(+0000001): Committed DB transaction Btu5oCVE
(3)(+0000000): [Actions and Tags for Zotero] applyAction {"event":0,"operation":4,"data":"// @author windingwind, garth74\n// @link https://github.com/windingwind/zotero-actions-tags/discussions/115\n// @Usage Select an item in the library and press the assigned shortcut keys\n// @update Mon, 22 Jan 2024 00:10:18 GMT (by new Date().toGMTString())\n\n// EDIT THESE SETTINGS\n\n/** @type {string} Name of the field to use as the link text. To use the citation key, set this to "citationKey". /\nlet linkTextField = "title";\n\n/* @type {'html' | 'md' | 'plain'} What type of link to create. /\nlet linkType = "html";\n\n/* @type {boolean} If true, make the link specific to the currently selected collection. /\nlet useColl = false;\n\n/* @type {boolean} If true, use Better Notes zotero://note link when the selected item is a note. /\nlet useNoteLink = false;\n\n/* @type {'select' | 'open-pdf' | 'auto'} Action of link*/\nlet linkAction = "auto"; // auto = open-pdf for PDFs and annotations, select for everything else\n\n// END OF EDITABLE SETTINGS\n\n// For efficiency, only execute once for all selected items\nif (item) return;\nitem = items[0];\nif (!item && !collection) return "[Copy Zotero Link] item is empty";\n\nif (collection) {\n linkAction = "select";\n useColl = true;\n}\n\nif (linkAction === "auto") {\n if (item.isPDFAttachment() || item.isAnnotation()) {\n linkAction = "open-pdf";\n } else {\n linkAction = "select";\n }\n}\n\nconst uriParts = [];\nlet uriParams = "";\n\nlet targetItem = item;\nif (linkAction === "open-pdf") {\n uriParts.push("zotero://open-pdf");\n if (item.isRegularItem()) {\n targetItem = (await item.getBestAttachments()).find((att) =>\n att.isPDFAttachment()\n );\n } else if (item.isAnnotation()) {\n targetItem = item.parentItem;\n // If the item is an annotation, we want to open the PDF at the page of the annotation\n let pageIndex = 1;\n try {\n pageIndex = JSON.parse(item.annotationPosition).pageIndex + 1;\n } catch (e) {\n Zotero.warn(e);\n }\n uriParams = ?page=${pageIndex}&annotation=${item.key}
;\n }\n} else {\n uriParts.push("zotero://select");\n if (item?.isAnnotation()) {\n targetItem = item.parentItem;\n }\n}\n\nif (!targetItem && !collection) return "[Copy Zotero Link] item is invalid";\n\n// Get the link text using the link_text_field
argument\nlet linkText;\nif (collection) {\n // When collection
is truthy, this script was triggered in the collection menu.\n // Use collection name if this is a collection link\n linkText = collection.name;\n} else if (item.isAttachment()) {\n // Try to use top-level item for link text\n linkText = Zotero.Items.getTopLevel([item])[0].getField(linkTextField);\n} else if (item.isAnnotation()) {\n // Add the annotation text to the link text\n linkText = ${targetItem.getField(linkTextField)}(${\n item.annotationComment || item.annotationText || \"annotation\"\n })
;\n} else {\n // Use the item's field\n linkText = item.getField(linkTextField);\n}\n\n// Add the library or group URI part (collection must go first)\nlet libraryType = (collection || item).library.libraryType;\nif (libraryType === "user") {\n uriParts.push("library");\n} else {\n uriParts.push(\n groups/${Zotero.Libraries.get((collection || item).libraryID).groupID}
\n );\n}\n\n// If useColl, make the link collection specific\nif (useColl) {\n // see https://forums.zotero.org/discussion/73893/zotero-select-for-collections\n let coll = collection || Zotero.getActiveZoteroPane().getSelectedCollection();\n\n // It's possible that a collection isn't selected. When that's the case,\n // this will fall back to the typical library behavior.\n\n // If a collection is selected, add the collections URI part\n if (!!coll) uriParts.push(collections/${coll.key}
);\n}\n\nif (!collection) {\n // Add the item URI part\n uriParts.push(items/${targetItem.key}
);\n}\n\n// Join the parts together\nlet uri = uriParts.join("/");\n\n// Add the URI parameters\nif (uriParams) {\n uri += uriParams;\n}\n\nif (useNoteLink && item?.isNote() && Zotero.BetterNotes) {\n uri = Zotero.BetterNotes.api.convert.note2link(item);\n}\n\n// Format the link and copy it to the clipboard\nconst clipboard = new Zotero.ActionsTags.api.utils.ClipboardHelper();\nif (linkType == "html") {\n clipboard.addText(<a href=\"${uri}\">${linkText}</a>
, "text/unicode");\n} else if (linkType == "md") {\n clipboard.addText([${linkText}](${uri})
, "text/unicode");\n} else {\n clipboard.addText(uri, "text/unicode");\n}\n\nclipboard.addText(<a href=\"${uri}\">${linkText}</a>
, "text/html");\n\nclipboard.copy();\n\nreturn [Copy Zotero Link] link ${uri} copied.
;","shortcut":"Shift,Ctrl,Alt,I","enabled":true,"menu":"Copy Link","name":"Copy Zotero Link","showInMenu":{"item":true,"collection":true,"tools":true,"reader":true,"readerAnnotation":true}} {"itemID":83416,"triggerType":"menu"}
(4)(+0006573): Registering notifier observer 'tagsBox_NY' for [item-tag,setting] with priority 101
(4)(+0000001): Registering notifier observer 'relatedbox_3X' for [item]
(4)(+0000000): Registering notifier observer 'noteEditor_vU' for [item,file]
(3)(+0000085): Reloading tags box
(4)(+0000000): Registering notifier observer 'noteWindow_my' for [item]
(3)(+0000101): itemTree.render(). Displaying Item Tree
(4)(+0002860): Unregistering notifier observer in notifier with id 'noteWindow_my'
(4)(+0000000): Unregistering notifier observer in notifier with id 'noteEditor_vU'
(3)(+0000001): No pref observer registered for given symbol
(4)(+0000000): Unregistering notifier observer in notifier with id 'tagsBox_NY'
(3)(+0000000): No pref observer registered for given symbol
(4)(+0000000): Unregistering notifier observer in notifier with id 'relatedbox_3X'
Anything else?
No response