Fix broken Export Library after #2214

This commit is contained in:
Dan Stillman 2021-12-18 22:41:21 -05:00
parent 78526d7795
commit f734e53ed9

View file

@ -49,12 +49,12 @@ var Zotero_File_Exporter = function() {
Zotero_File_Exporter.prototype.save = async function () {
var translation = new Zotero.Translate.Export();
var translators = await translation.getTranslators();
translators.sort((a, b) => a.label.localeCompare(b.label));
if (!this.items) {
return;
}
let exportingNotes = this.items.every(item => item.isNote() || item.isAttachment());
// If exporting items, check whether they're only notes to determine which translators to show
let exportingNotes = false;
if (this.items) {
exportingNotes = this.items.every(item => item.isNote() || item.isAttachment());
// Keep only note export and Zotero RDF translators, if all items are notes or attachments
if (exportingNotes) {
translators = translators.filter((translator) => {
@ -63,13 +63,6 @@ Zotero_File_Exporter.prototype.save = async function () {
|| translator.configOptions && translator.configOptions.noteTranslator
);
});
}
// Otherwise exclude note export translators
else {
translators = translators.filter(t => !t.configOptions || !t.configOptions.noteTranslator);
}
translators.sort((a, b) => a.label.localeCompare(b.label));
// Remove "Note" prefix from Note Markdown and Note HTML translators
let markdownTranslator = translators.find(
@ -86,6 +79,12 @@ Zotero_File_Exporter.prototype.save = async function () {
if (htmlTranslator) {
htmlTranslator.label = 'HTML';
}
}
// Otherwise exclude note export translators
else {
translators = translators.filter(t => !t.configOptions || !t.configOptions.noteTranslator);
}
}
// present options dialog
var io = { translators, exportingNotes };