fix: template preview

This commit is contained in:
windingwind 2024-03-28 21:01:22 +08:00
parent 1287ccc900
commit d8e29cedc8

View File

@ -78,16 +78,15 @@ async function renderTemplatePreview(
const link = getNoteLink(data);
const linkText = data.getNoteTitle().trim() || link;
const subNoteItem = data;
return "";
// const noteItem = Zotero.Items.get(addon.data.workspace.mainId);
// html = await addon.api.template.runTemplate(
// templateName,
// "link, linkText, subNoteItem, noteItem",
// [link, linkText, subNoteItem, noteItem],
// {
// dryRun: true,
// },
// );
const noteItem = new Zotero.Item("note");
html = await addon.api.template.runTemplate(
templateName,
"link, linkText, subNoteItem, noteItem",
[link, linkText, subNoteItem, noteItem],
{
dryRun: true,
},
);
}
} else if (templateName.includes("QuickBackLink")) {
// link, linkText, subNoteItem, noteItem
@ -95,19 +94,18 @@ async function renderTemplatePreview(
if (!data) {
html = "<p>No note item selected</p>";
} else {
return "";
// const link = getNoteLink(data);
// const noteItem = Zotero.Items.get(addon.data.workspace.mainId);
// const linkText = noteItem.getNoteTitle().trim() || "Workspace Note";
// const subNoteItem = data;
// html = await addon.api.template.runTemplate(
// templateName,
// "link, linkText, subNoteItem, noteItem",
// [link, linkText, subNoteItem, noteItem],
// {
// dryRun: true,
// },
// );
const link = getNoteLink(data);
const noteItem = new Zotero.Item("note");
const linkText = noteItem.getNoteTitle().trim() || "Workspace Note";
const subNoteItem = data;
html = await addon.api.template.runTemplate(
templateName,
"link, linkText, subNoteItem, noteItem",
[link, linkText, subNoteItem, noteItem],
{
dryRun: true,
},
);
}
} else if (templateName.includes("QuickImport")) {
// link, noteItem
@ -115,17 +113,16 @@ async function renderTemplatePreview(
if (!data) {
html = "<p>No note item selected</p>";
} else {
return "";
// const link = getNoteLink(data);
// const noteItem = Zotero.Items.get(addon.data.workspace.mainId);
// html = await addon.api.template.runTemplate(
// templateName,
// "link, noteItem",
// [link, noteItem],
// {
// dryRun: true,
// },
// );
const link = getNoteLink(data);
const noteItem = new Zotero.Item("note");
html = await addon.api.template.runTemplate(
templateName,
"link, noteItem",
[link, noteItem],
{
dryRun: true,
},
);
}
} else if (templateName.includes("QuickNote")) {
// annotationItem, topItem, noteItem