diff --git a/chrome/content/zotero/import/importWizard.js b/chrome/content/zotero/import/importWizard.js index eeac19fdc8..482bc31232 100644 --- a/chrome/content/zotero/import/importWizard.js +++ b/chrome/content/zotero/import/importWizard.js @@ -61,7 +61,7 @@ const Zotero_Import_Wizard = { // eslint-disable-line no-unused-vars }, async init() { - const { mendeleyCode, libraryID } = window.arguments[0].wrappedJSObject ?? {}; + const { mendeleyCode, libraryID, pageID } = window.arguments[0].wrappedJSObject ?? {}; this.libraryID = libraryID; @@ -125,6 +125,10 @@ const Zotero_Import_Wizard = { // eslint-disable-line no-unused-vars this.wizard.shadowRoot .querySelector('.wizard-header-label').style.fontSize = '16px'; + if (pageID) { + this.wizard.goTo(pageID); + } + if (mendeleyCode && Zotero.Prefs.get("import.mendeleyUseOAuth")) { this.mendeleyCode = mendeleyCode; this.wizard.goTo('page-options'); diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 76a79a3b07..c3561710d3 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -2655,11 +2655,42 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = async function (uris) replacer = await Zotero.Relations.getByPredicateAndObject( 'item', 'mendeleyDB:documentUUID', m[1] ); - if (replacer.length && !replacer[0].deleted) { - zoteroItem = replacer[0]; - break; + if (replacer.length) { + if (!replacer[0].deleted) { + zoteroItem = replacer[0]; + break; + } } - } + // If not blocked by user having pressed skip in this session, + // or user having checked the checkbox to not be prompted about this, + // or user having imported their library with the new version of importer + else if (!(this.session.dontPromptForMendeley + || Zotero.Prefs.get('integration.dontPromptMendeleyImport') + || await Zotero.DB.valueQueryAsync("SELECT value FROM settings WHERE setting='mendeleyImport' AND key='version'") + )) { + // Prompt user to (re)import their mendeley database which might make us recognize + // these items + let checkbox = {}; + let result = Zotero.Prompt.confirm({ + title: Zotero.getString('integration.mendeleyImport.title'), + text: Zotero.getString('integration.mendeleyImport.description', [Zotero.appName]), + button0: Zotero.getString('integration.mendeleyImport.openImporter'), + button1: Zotero.getString('general.skip'), + checkLabel: Zotero.getString('general.dontAskAgain'), + checkbox + }); + if (result === 0) { + setTimeout(() => Zotero.getMainWindow().Zotero_File_Interface.showImportWizard({ pageID: 'page-mendeley-online-intro' })); + throw new Zotero.Exception.UserCancelled("Importing mendeley citations"); + } + else { + this.session.dontPromptForMendeley = true; + } + if (checkbox.value) { + Zotero.Prefs.set('integration.dontPromptMendeleyImport', true); + } + } + }; } diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 25e339b113..7cbe8ec7ac 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -73,6 +73,7 @@ general.tryLater = Try Later general.showDirectory = Show Directory general.showInLibrary = Show in Library general.continue = Continue +general.skip = Skip general.copy = Copy general.copyToClipboard = Copy to Clipboard general.cancel = Cancel @@ -992,6 +993,9 @@ integration.exportDocument.description1 = Zotero will convert citations in the d integration.exportDocument.description2 = You should make a backup of the document before proceeding. integration.importInstructions = The Zotero citations in this document have been converted to a format that can be safely transferred between word processors. Open this document in a supported word processor and press Refresh in the Zotero plugin to continue working with the citations. integration.upgradeTemplate = The %S plugin for %S is outdated. Reinstall the plugin from Preferences → Cite → Word Processors. +integration.mendeleyImport.title = Missing Mendeley Data +integration.mendeleyImport.description = %1$S detected that the document you are citing with contains Mendeley citations. %1$S will be able to manage these citations if you import your Mendeley database. +integration.mendeleyImport.openImporter = Open Mendeley Importer... styles.install.title = Install Style styles.install.unexpectedError = An unexpected error occurred while installing "%1$S" diff --git a/components/zotero-service.js b/components/zotero-service.js index f09160fb99..ae0ccc6d67 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -53,6 +53,7 @@ const xpcomFilesAll = [ 'mimeTypeHandler', 'pdfWorker/manager', 'ipc', + 'prompt', 'profile', 'progressWindow', 'proxy', diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js index 124473cea2..59793b91ea 100644 --- a/defaults/preferences/zotero.js +++ b/defaults/preferences/zotero.js @@ -135,6 +135,7 @@ pref("extensions.zotero.integration.autoRegenerate", -1); // -1 = ask; 0 = no; 1 pref("extensions.zotero.integration.useClassicAddCitationDialog", false); pref("extensions.zotero.integration.keepAddCitationDialogRaised", false); pref("extensions.zotero.integration.upgradeTemplateDelayedOn", 0); +pref("extensions.zotero.integration.dontPromptMendeleyImport", false); // Connector settings pref("extensions.zotero.httpServer.enabled", true);