parent
65329dbf27
commit
8799de5284
2 changed files with 16 additions and 9 deletions
|
@ -30,7 +30,7 @@ Zotero.Report.HTML = new function () {
|
|||
let domParser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Components.interfaces.nsIDOMParser);
|
||||
|
||||
this.listGenerator = function* (items, combineChildItems) {
|
||||
this.listGenerator = function* (items, combineChildItems, libraryID) {
|
||||
yield '<!DOCTYPE html>\n'
|
||||
+ '<html>\n'
|
||||
+ ' <head>\n'
|
||||
|
@ -69,7 +69,7 @@ Zotero.Report.HTML = new function () {
|
|||
// Independent note
|
||||
if (obj['note']) {
|
||||
content += '\n\t\t\t';
|
||||
content += getNoteHTML(obj.note);
|
||||
content += yield getNoteHTML(libraryID, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ Zotero.Report.HTML = new function () {
|
|||
for (let note of obj.reportChildren.notes) {
|
||||
content += '\t\t\t\t\t<li id="item_' + note.key + '">\n';
|
||||
|
||||
content += getNoteHTML(note.note);
|
||||
content += yield getNoteHTML(libraryID, note);
|
||||
|
||||
// Child note tags
|
||||
content += _generateTagsList(note);
|
||||
|
@ -95,8 +95,8 @@ Zotero.Report.HTML = new function () {
|
|||
content += '\t\t\t\t</ul>\n';
|
||||
}
|
||||
|
||||
// Chid attachments
|
||||
content += _generateAttachmentsList(obj.reportChildren);
|
||||
// Child attachments
|
||||
content += yield _generateAttachmentsList(libraryID, obj.reportChildren);
|
||||
}
|
||||
|
||||
// Related items
|
||||
|
@ -273,7 +273,7 @@ Zotero.Report.HTML = new function () {
|
|||
}
|
||||
|
||||
|
||||
function _generateAttachmentsList(obj) {
|
||||
async function _generateAttachmentsList(libraryID, obj) {
|
||||
var content = '';
|
||||
if (obj.attachments && obj.attachments.length) {
|
||||
content += '\t\t\t\t<h3 class="attachments">' + escapeXML(Zotero.getString('itemFields.attachments')) + '</h3>\n';
|
||||
|
@ -292,7 +292,7 @@ Zotero.Report.HTML = new function () {
|
|||
// Attachment note
|
||||
if (attachment.note) {
|
||||
content += '\t\t\t\t\t\t<div class="note">';
|
||||
content += getNoteHTML(attachment.note);
|
||||
content += await getNoteHTML(libraryID, attachment);
|
||||
content += '\t\t\t\t\t</div>';
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,14 @@ Zotero.Report.HTML = new function () {
|
|||
}
|
||||
|
||||
|
||||
function getNoteHTML(note) {
|
||||
async function getNoteHTML(libraryID, jsonItem) {
|
||||
var note = jsonItem.note;
|
||||
if (libraryID) {
|
||||
var item = Zotero.Items.getByLibraryAndKey(libraryID, jsonItem.key);
|
||||
if (item.isNote()) {
|
||||
note = await Zotero.Notes.getExportableNote(item);
|
||||
}
|
||||
}
|
||||
// If HTML tag or entity, parse as HTML
|
||||
if (note.match(/(<(p|ul|ol|div|a|br|b|i|u|strong|em( >))|&[a-z]+;|&#[0-9]+;)/)) {
|
||||
let doc = domParser.parseFromString('<div>'
|
||||
|
|
|
@ -510,7 +510,7 @@ function ZoteroProtocolHandler() {
|
|||
default:
|
||||
this.contentType = 'text/html';
|
||||
return Zotero.Utilities.Internal.getAsyncInputStream(
|
||||
Zotero.Report.HTML.listGenerator(items, combineChildItems),
|
||||
Zotero.Report.HTML.listGenerator(items, combineChildItems, params.libraryID),
|
||||
function () {
|
||||
Zotero.logError(e);
|
||||
return '<span style="color: red; font-weight: bold">Error generating report</span>';
|
||||
|
|
Loading…
Reference in a new issue