Convert plaintext notes on the fly, to deal with multi-version syncing issues
This commit is contained in:
parent
71ca2c1b2c
commit
47285a0567
2 changed files with 18 additions and 4 deletions
|
@ -228,7 +228,7 @@
|
|||
var html = val;
|
||||
|
||||
if(this._format == "Integration" || this._format == "RTF") {
|
||||
bodyStyle = "";
|
||||
var bodyStyle = "";
|
||||
if(html.substr(0, 3) == "\\li") {
|
||||
// try to show paragraph formatting
|
||||
var returnIndex = html.indexOf("\r\n");
|
||||
|
|
|
@ -1242,7 +1242,7 @@ Zotero.Item.prototype.save = function() {
|
|||
var parent = this.isNote() ? this.getSource() : null;
|
||||
var noteText = this._noteText ? this._noteText : '';
|
||||
// Add <div> wrapper if not present
|
||||
if (!noteText.match(/^<div class="zotero\-note znv[0-9]+">.*<\/div>$/)) {
|
||||
if (!noteText.match(/^<div class="zotero-note znv[0-9]+">[\s\S]*<\/div>$/)) {
|
||||
noteText = '<div class="zotero-note znv1">' + noteText + '</div>';
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1583,7 @@ Zotero.Item.prototype.save = function() {
|
|||
var parent = this.isNote() ? this.getSource() : null;
|
||||
var noteText = this._noteText;
|
||||
// Add <div> wrapper if not present
|
||||
if (!noteText.match(/^<div class="zotero\-note znv[0-9]+">.*<\/div>$/)) {
|
||||
if (!noteText.match(/^<div class="zotero-note znv[0-9]+">[\s\S]*<\/div>$/)) {
|
||||
noteText = '<div class="zotero-note znv1">' + noteText + '</div>';
|
||||
}
|
||||
var bindParams = [
|
||||
|
@ -1994,8 +1994,22 @@ Zotero.Item.prototype.getNote = function() {
|
|||
|
||||
var sql = "SELECT note FROM itemNotes WHERE itemID=?";
|
||||
var note = Zotero.DB.valueQuery(sql, this.id);
|
||||
|
||||
// Convert non-HTML notes on-the-fly
|
||||
if (!note.match(/^<div class="zotero-note znv[0-9]+">[\s\S]*<\/div>$/)) {
|
||||
note = Zotero.Utilities.prototype.htmlSpecialChars(note);
|
||||
note = '<p>'
|
||||
+ note.replace(/\n/g, '</p><p>')
|
||||
.replace(/\t/g, ' ')
|
||||
.replace(/ /g, ' ')
|
||||
+ '</p>';
|
||||
note = note.replace(/<p>\s*<\/p>/g, '<p> </p>');
|
||||
var sql = "UPDATE itemNotes SET note=? WHERE itemID=?";
|
||||
Zotero.DB.query(sql, [note, this.id]);
|
||||
}
|
||||
|
||||
// Don't include <div> wrapper when returning value
|
||||
note = note.replace(/^<div class="zotero-note znv[0-9]+">(.*)<\/div>$/, '$1');
|
||||
note = note.replace(/^<div class="zotero-note znv[0-9]+">([\s\S]*)<\/div>$/, '$1');
|
||||
|
||||
this._noteText = note ? note : '';
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue