fix: zotero 7 template preview bug

This commit is contained in:
windingwind 2023-04-10 19:46:41 +08:00
parent fb77d7e126
commit dd57ef066e
2 changed files with 9 additions and 5 deletions

View File

@ -184,10 +184,14 @@ async function updatePreview() {
const win = addon.data.templateEditor.window;
const container = win?.document.getElementById("preview-container");
if (container) {
container.innerHTML = "";
container.appendChild(
ztoolkit.getDOMParser().parseFromString(html, "text/html").body
);
if (ztoolkit.isZotero7()) {
container.innerHTML = html;
} else {
container.innerHTML = "";
container.appendChild(
ztoolkit.getDOMParser().parseFromString(html, "text/html").body
);
}
}
}

View File

@ -8,7 +8,7 @@ async function renderTemplatePreview(
inputItems?: Zotero.Item[]
): Promise<string> {
let html: string = "<p>Preview rendering failed</p>";
if (inputItems) {
if (!inputItems) {
inputItems = ZoteroPane.getSelectedItems();
}
if (templateName.startsWith("[Text]")) {