www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit b985ef8a53e9d37b38ebb6c2628da4522ae66aff
parent 4b78ebcd727aa82fd5fb45ffb5c84cb0cd90a58f
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date:   Tue, 12 Dec 2017 14:21:42 +0200

Ensure delayed citation styling is removed upon proper update

Ensure delayed citation styling is removed upon proper update

Diffstat:
Mchrome/content/zotero/xpcom/integration.js | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js @@ -52,6 +52,8 @@ const INTEGRATION_TYPE_BIBLIOGRAPHY = 2; const INTEGRATION_TYPE_TEMP = 3; const DELAY_CITATIONS_PROMPT_TIMEOUT = 5/*seconds*/; +const DELAYED_CITATION_STYLING = "\\uldash"; +const DELAYED_CITATION_STYLING_CLEAR = "\\ulclear"; Zotero.Integration = new function() { @@ -1003,7 +1005,13 @@ Zotero.Integration.Fields.prototype._updateDocument = async function(forceCitati } if(!citation.properties.dontUpdate) { - isRich = citationField.setText(formattedCitation); + // Word will preserve previous text styling, so we need to force remove it + // for citations that were inserted with delay styling + if (citation.properties.formattedCitation && citation.properties.formattedCitation.includes(DELAYED_CITATION_STYLING)) { + isRich = citationField.setText(`${DELAYED_CITATION_STYLING_CLEAR}{${formattedCitation}}`); + } else { + isRich = citationField.setText(formattedCitation); + } citation.properties.formattedCitation = formattedCitation; citation.properties.plainCitation = citationField.getText(); @@ -1590,7 +1598,7 @@ Zotero.Integration.Session.prototype.writeDelayedCitation = Zotero.Promise.corou } catch(e) { throw e; } - text = `\\uldash{${text}}`; + text = `${DELAYED_CITATION_STYLING}{${text}}`; // Make sure we'll prompt for manually edited citations var isRich = false; @@ -2223,7 +2231,7 @@ Zotero.Integration.BibliographyField = class extends Zotero.Integration.Field { } } - resolveCorrupt() { + resolveCorrupt(code) { return Zotero.Promise.coroutine(function* () { Zotero.debug(`Integration: handling corrupt bibliography field ${code}`); var msg = Zotero.getString("integration.corruptBibliography")+'\n\n'+