From 912b6a088f65aeac2fbdf17bc289b502fc76b14a Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:00:54 +0800 Subject: [PATCH] fix: runItemTemplate bug --- src/modules/template/api.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/template/api.ts b/src/modules/template/api.ts index 762fdb9..b4b8d0e 100644 --- a/src/modules/template/api.ts +++ b/src/modules/template/api.ts @@ -147,7 +147,12 @@ async function runItemTemplate( return ""; } - const targetNoteItem = Zotero.Items.get(targetNoteId || -1); + let targetNoteItem: Zotero.Item | undefined = Zotero.Items.get( + targetNoteId || -1, + ); + if (!targetNoteItem) { + targetNoteItem = undefined; + } const items = itemIds?.map((id) => Zotero.Items.get(id)) || [];