From f409868c64ffbc300810fd47a848bdaa469175d7 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 25 Nov 2025 13:28:45 -0500 Subject: [PATCH 1/2] Show warning on one-way or whole-library export --- chrome/content/zotero/exportOptions.js | 21 +++++++++++++++++++-- chrome/content/zotero/exportOptions.xhtml | 13 +++++++++---- chrome/content/zotero/fileInterface.js | 6 +++++- chrome/locale/en-US/zotero/zotero.ftl | 3 +++ scss/components/_exportOptions.scss | 19 +++++++++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/exportOptions.js b/chrome/content/zotero/exportOptions.js index e78f51366a..e78de7cbb2 100644 --- a/chrome/content/zotero/exportOptions.js +++ b/chrome/content/zotero/exportOptions.js @@ -31,6 +31,13 @@ const OPTION_PREFIX = "export-option-"; +const IGNORE_IMPORT_ONLY = [ + 'b6e39b57-8942-4d11-8259-342c46ce395f', // BibLaTeX: Imported by BibTeX + '14763d25-8ba0-45df-8f52-b8d1108e7ac9', // Bibliontology RDF: Imported by RDF + '14763d24-8ba0-45df-8f52-b8d1108e7ac9', // Zotero RDF: Imported by RDF + '6e372642-ed9d-4934-b5d1-c11ac758ebb7', // Unqualified Dublin Core RDF: Imported by RDF +]; + // Class to provide options for export var Zotero_File_Interface_Export = new function() { @@ -49,7 +56,7 @@ var Zotero_File_Interface_Export = new function() { var addedOptions = new Object(); - var { translators, exportingNotes } = window.arguments[0]; + var { translators, exportingNotes, exportingLibrary } = window.arguments[0]; // get format popup var formatPopup = document.getElementById("format-popup"); @@ -138,6 +145,9 @@ var Zotero_File_Interface_Export = new function() { exportingNotes ? "export.noteTranslatorSettings" : "export.translatorSettings" )); + var warningBackup = document.getElementById('warning-backup'); + warningBackup.hidden = !exportingLibrary; + document.addEventListener('dialogaccept', () => this.accept()); document.addEventListener('dialogcancel', () => this.cancel()); } @@ -148,7 +158,8 @@ var Zotero_File_Interface_Export = new function() { this.updateOptions = function (optionString) { // get selected translator var index = document.getElementById("format-menu").selectedIndex; - var translatorOptions = window.arguments[0].translators[index].displayOptions; + var translator = window.arguments[0].translators[index]; + var translatorOptions = translator.displayOptions; if(optionString) { try { @@ -215,6 +226,12 @@ var Zotero_File_Interface_Export = new function() { document.getElementById("charset-box").hidden = true; } + let warningCannotImport = document.getElementById('warning-cannot-import'); + warningCannotImport.hidden = translator.translatorType & Zotero.Translator.TRANSLATOR_TYPES.import + || IGNORE_IMPORT_ONLY.includes(translator.translatorID); + document.l10n.setArgs(warningCannotImport, { format: translator.label }); + document.l10n.translateRoots().then(() => window.sizeToContent()); + window.sizeToContent(); } diff --git a/chrome/content/zotero/exportOptions.xhtml b/chrome/content/zotero/exportOptions.xhtml index 9087cd509e..38ca02d669 100644 --- a/chrome/content/zotero/exportOptions.xhtml +++ b/chrome/content/zotero/exportOptions.xhtml @@ -7,7 +7,6 @@ %zoteroDTD; ]> + + + + @@ -38,6 +39,7 @@ + + diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 97da1dd6e0..1d9c6d5123 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -103,7 +103,11 @@ Zotero_File_Exporter.prototype.save = async function () { } // present options dialog - var io = { translators, exportingNotes }; + var io = { + translators, + exportingNotes, + exportingLibrary: !!(this.libraryID && !this.collection && !this.items), + }; window.openDialog("chrome://zotero/content/exportOptions.xhtml", "_blank", "chrome,modal,centerscreen,resizable=no", io); if(!io.selectedTranslator) { diff --git a/chrome/locale/en-US/zotero/zotero.ftl b/chrome/locale/en-US/zotero/zotero.ftl index 03a5e94c59..26f0504f8e 100644 --- a/chrome/locale/en-US/zotero/zotero.ftl +++ b/chrome/locale/en-US/zotero/zotero.ftl @@ -278,6 +278,9 @@ import-online-new = import-mendeley-username = Username import-mendeley-password = Password +export-warning-cannot-import = { -app-name } cannot import data in { $format }. Only exports are supported using this format. +export-warning-backup = You may lose data if you attempt to back up your entire library this way. + general-error = Error file-interface-import-error = An error occurred while trying to import the selected file. Please ensure that the file is valid and try again. file-interface-import-complete = Import Complete diff --git a/scss/components/_exportOptions.scss b/scss/components/_exportOptions.scss index 8b1da82f78..99f9b9fc8e 100644 --- a/scss/components/_exportOptions.scss +++ b/scss/components/_exportOptions.scss @@ -13,4 +13,23 @@ checkbox[native][disabled="true"] { color: unset; } + + #warning-cannot-import, #warning-backup { + max-width: 300px; + white-space: wrap; + } + + #warning-cannot-import { + color: var(--fill-secondary); + padding-inline-start: 8px; + padding-bottom: 2px; + } + + #warning-backup { + color: var(--accent-red); + + .zotero-text-link { + margin: 0; + } + } } From 15305e6f6dadf2c2cfe5d4998dd7ccf41a8a7c4c Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 25 Nov 2025 13:36:42 -0500 Subject: [PATCH 2/2] Correct constant name --- chrome/content/zotero/exportOptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/exportOptions.js b/chrome/content/zotero/exportOptions.js index e78de7cbb2..2410252812 100644 --- a/chrome/content/zotero/exportOptions.js +++ b/chrome/content/zotero/exportOptions.js @@ -31,7 +31,7 @@ const OPTION_PREFIX = "export-option-"; -const IGNORE_IMPORT_ONLY = [ +const IGNORE_EXPORT_ONLY_TRANSLATORS = [ 'b6e39b57-8942-4d11-8259-342c46ce395f', // BibLaTeX: Imported by BibTeX '14763d25-8ba0-45df-8f52-b8d1108e7ac9', // Bibliontology RDF: Imported by RDF '14763d24-8ba0-45df-8f52-b8d1108e7ac9', // Zotero RDF: Imported by RDF @@ -228,7 +228,7 @@ var Zotero_File_Interface_Export = new function() { let warningCannotImport = document.getElementById('warning-cannot-import'); warningCannotImport.hidden = translator.translatorType & Zotero.Translator.TRANSLATOR_TYPES.import - || IGNORE_IMPORT_ONLY.includes(translator.translatorID); + || IGNORE_EXPORT_ONLY_TRANSLATORS.includes(translator.translatorID); document.l10n.setArgs(warningCannotImport, { format: translator.label }); document.l10n.translateRoots().then(() => window.sizeToContent());