From 95a0f4916d2d19b2894480c99e7024f40268913e Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:17:19 +0100 Subject: [PATCH] add: api.convert.note2html dryRun flag fix: note2html for preview in link creator --- src/utils/convert.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/convert.ts b/src/utils/convert.ts index 2b7c776..fd6db56 100644 --- a/src/utils/convert.ts +++ b/src/utils/convert.ts @@ -262,18 +262,23 @@ function annotations2html( async function note2html( noteItems: Zotero.Item | Zotero.Item[], - options: { targetNoteItem?: Zotero.Item; html?: string } = {}, + options: { + targetNoteItem?: Zotero.Item; + html?: string; + dryRun?: boolean; + } = {}, ) { if (!Array.isArray(noteItems)) { noteItems = [noteItems]; } - const { targetNoteItem } = options; + const { targetNoteItem, dryRun } = options; let html = options.html; if (!html) { html = noteItems.map((item) => item.getNote()).join("\n"); } - if (targetNoteItem?.isNote()) { - return await copyEmbeddedImagesInHTML(html, targetNoteItem, noteItems); + if (!dryRun && targetNoteItem?.isNote()) { + const str = await copyEmbeddedImagesInHTML(html, targetNoteItem, noteItems); + return str; } return await renderNoteHTML(html, noteItems); }