Fix undefined variable issue in annotation templates

This commit is contained in:
Martynas Bagdonas 2022-04-26 08:26:01 +02:00
parent d96ebad82a
commit 7a06671ecb

View file

@ -1359,13 +1359,15 @@ class EditorInstanceUtilities {
}
let vars = {
color: annotation.color,
color: annotation.color || '',
highlight: (attrs) => attrs.quotes === 'true' ? quotedHighlightHTML : highlightHTML,
comment: commentHTML,
citation: citationHTML,
image: imageHTML,
tags: (attrs) => annotation.tags && annotation.tags.map(tag => tag.name).join(attrs.join || ' ')
tags: (attrs) => (annotation.tags && annotation.tags.map(tag => tag.name) || []).join(attrs.join || ' ')
};
Zotero.debug('Using note template:');
Zotero.debug(template);
let templateHTML = Zotero.Utilities.Internal.generateHTMLFromTemplate(template, vars);
// Remove some spaces at the end of paragraph
templateHTML = templateHTML.replace(/([\s]*)(<\/p)/g, '$2');