diff --git a/chrome/content/zotero/tinymce/note.html b/chrome/content/zotero/tinymce/note.html index 1544cb61c..e4a8d3026 100755 --- a/chrome/content/zotero/tinymce/note.html +++ b/chrome/content/zotero/tinymce/note.html @@ -12,7 +12,7 @@ content_css : "css/note-content.css", button_tile_map : true, language : "en", // TODO: localize - entity_encoding : "raw", + entities : "160,nbsp", gecko_spellcheck : true, handle_event_callback : function (event) { diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index a5dd112fb..3eb5a2b23 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3679,21 +3679,42 @@ Zotero.Item.prototype.diff = function (item, includeMatches, ignoreFields) { } if (thisData.note != undefined) { - // replace() keeps Windows newlines from triggering erroneous conflicts, - // though this should really be fixed at the data layer level + // Whitespace normalization // - // Using a try/catch to avoid unexpected errors in 2.1 Final + // Ideally this would all be fixed elsewhere so we didn't have to + // convert on every sync diff + // + // TEMP: Using a try/catch to avoid unexpected errors in 2.1 releases try { - changed = thisData.note.replace(/\r\n/g, "\n") != otherData.note.replace(/\r\n/g, "\n"); + var thisNote = thisData.note; + var otherNote = otherData.note; + + // Stop Windows newlines from triggering erroneous conflicts + thisNote = thisNote.replace(/\r\n/g, "\n"); + otherNote = otherNote.replace(/\r\n/g, "\n"); + + // Normalize multiple spaces (due to differences TinyMCE, Z.U.text2html(), + // and the server) + var re = /( | |\u00a0 |\u00a0\u00a0)/g; + thisNote = thisNote.replace(re, " "); + otherNote = otherNote.replace(re, " "); + + // Normalize new paragraphs + var re = /
( |\u00a0)<\/p>/g; + thisNote = thisNote.replace(re, "
"); + otherNote = otherNote.replace(re, "
"); + + changed = thisNote != otherNote; } catch (e) { Zotero.debug(e); Components.utils.reportError(e); - changed = thisData.note != otherData.note; + changed = thisNote != otherNote; } + if (includeMatches || changed) { - diff[0].note = thisData.note; - diff[1].note = otherData.note; + diff[0].note = thisNote; + diff[1].note = otherNote; } if (changed) { diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 4175ada15..ea95e5f04 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -159,8 +159,7 @@ Zotero.Utilities = { if (singleNewlineIsParagraph) { str = '
' + str.replace(/\n/g, '
') - .replace(/\t/g, ' ') - .replace(/ /g, ' ') + .replace(/ /g, ' ') + '
'; } // \n\n =>, \n =>
@@ -169,8 +168,7 @@ Zotero.Utilities = {
str = '
' + str.replace(/\n\n/g, '
')
.replace(/\n/g, '
')
- .replace(/\t/g, ' ')
- .replace(/ /g, ' ')
+ .replace(/ /g, ' ')
+ '
\s*<\/p>/g, '
');