diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 9fffaa1815..ff21c4a69d 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -1163,6 +1163,7 @@ var Zotero_QuickFormat = new function () { accepted = true; io.citation.citationItems = []; io.accept(); + window.close(); } }; diff --git a/chrome/content/zotero/xpcom/connector/httpIntegrationClient.js b/chrome/content/zotero/xpcom/connector/httpIntegrationClient.js index 080aac5a05..74e9d7547e 100644 --- a/chrome/content/zotero/xpcom/connector/httpIntegrationClient.js +++ b/chrome/content/zotero/xpcom/connector/httpIntegrationClient.js @@ -71,15 +71,16 @@ Zotero.HTTPIntegrationClient.Application.prototype = { this.supportsImportExport = result.supportsImportExport || this.supportsImportExport; this.supportsTextInsertion = result.supportsTextInsertion || this.supportsTextInsertion; this.processorName = result.processorName || this.processorName; - return new Zotero.HTTPIntegrationClient.Document(result.documentID); + return new Zotero.HTTPIntegrationClient.Document(result.documentID, this.processorName); } }; /** * See integrationTests.js */ -Zotero.HTTPIntegrationClient.Document = function(documentID) { +Zotero.HTTPIntegrationClient.Document = function(documentID, processorName) { this._documentID = documentID; + this.processorName = processorName; }; for (let method of ["activate", "canInsertField", "displayAlert", "getDocumentData", "setDocumentData", "setBibliographyStyle", "importDocument", "exportDocument", diff --git a/chrome/content/zotero/xpcom/connector/server_connectorIntegration.js b/chrome/content/zotero/xpcom/connector/server_connectorIntegration.js index 35cdf3117c..6628108b9f 100644 --- a/chrome/content/zotero/xpcom/connector/server_connectorIntegration.js +++ b/chrome/content/zotero/xpcom/connector/server_connectorIntegration.js @@ -64,14 +64,19 @@ Zotero.Server.Endpoints['/connector/document/respond'].prototype = { catch (e) {} if (data && data.error) { // Apps Script stack is a JSON object + let error = new Error("HTTP Integration Error"); if (typeof data.stack != "string") { data.stack = JSON.stringify(data.stack); } - let error = data; if (data.error == 'Alert') { error = new Zotero.Exception.Alert(data.message); error.stack = data.stack; } + else if (data.error == 'Tab Not Available Error') { + let client = Zotero.Integration.currentDoc.processorName || 'Google Docs'; + error = new Zotero.Exception.Alert(Zotero.getString('integration.error.tabUnavailable', client)); + error.stack = data.stack; + } Zotero.HTTPIntegrationClient.deferredResponse.reject(error); } else { Zotero.HTTPIntegrationClient.deferredResponse.resolve(data); diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index e66c67da47..7283a572f2 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -263,16 +263,19 @@ Zotero.Integration = new function() { } catch (e) { if (!(e instanceof Zotero.Exception.UserCancelled)) { - Zotero.Integration._handleCommandError(document, session, e); + await Zotero.Integration._handleCommandError(document, session, e); } else { if (session) { // If user cancels we should still write the currently assigned session ID - await document.setDocumentData(session.data.serialize()); - // And any citations marked for processing (like retraction warning ignore flag changes) - if (Object.keys(session.processIndices).length) { - session.updateDocument(FORCE_CITATIONS_FALSE, false, false); - } + try { + await document.setDocumentData(session.data.serialize()); + // And any citations marked for processing (like retraction warning ignore flag changes) + if (Object.keys(session.processIndices).length) { + session.updateDocument(FORCE_CITATIONS_FALSE, false, false); + } + // Since user cancelled we can ignore if processor fails here. + } catch(e) {} } } } @@ -366,9 +369,14 @@ Zotero.Integration = new function() { Zotero.Utilities.Internal.activate(); let ps = Services.prompt; - let index = ps.confirm(null, Zotero.getString('integration.error.title'), displayError); - if (index == 1) { - Zotero.launchURL(supportURL); + if (e instanceof Zotero.Exception.Alert) { + ps.alert(null, Zotero.getString('integration.error.title'), displayError); + } + else { + let index = ps.confirm(null, Zotero.getString('integration.error.title'), displayError); + if (index == 1) { + Zotero.launchURL(supportURL); + } } // CiteprocRsDriverError available only if citeproc-rs is enabled diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 8f1ede137f..f0d9be61f7 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -946,6 +946,7 @@ integration.error.macWordSBPermissionsMissing.pre2016 = If “Microsoft Word” integration.error.m1UpgradeOS.title = macOS Upgrade Required integration.error.m1UpgradeOS = Citing in Word on an Apple Silicon Mac with macOS 11.3 or earlier is not supported and may cause %S to freeze. Please upgrade to macOS 11.4 or later. integration.error.viewTroubleshootingInfo = Would you like to view troubleshooting instructions? +integration.error.tabUnavailable = The integration operation cannot be completed because the %S tab is no longer unavailable. integration.replace = Replace this Zotero field? integration.missingItem.single = The highlighted citation no longer exists in your Zotero database. Do you want to select a substitute item?