Convert plaintext notes on the fly, to deal with multi-version syncing issues
This commit is contained in:
parent
b29735e219
commit
4b94eeb519
|
@ -228,7 +228,7 @@
|
||||||
var html = val;
|
var html = val;
|
||||||
|
|
||||||
if(this._format == "Integration" || this._format == "RTF") {
|
if(this._format == "Integration" || this._format == "RTF") {
|
||||||
bodyStyle = "";
|
var bodyStyle = "";
|
||||||
if(html.substr(0, 3) == "\\li") {
|
if(html.substr(0, 3) == "\\li") {
|
||||||
// try to show paragraph formatting
|
// try to show paragraph formatting
|
||||||
var returnIndex = html.indexOf("\r\n");
|
var returnIndex = html.indexOf("\r\n");
|
||||||
|
|
|
@ -1242,7 +1242,7 @@ Zotero.Item.prototype.save = function() {
|
||||||
var parent = this.isNote() ? this.getSource() : null;
|
var parent = this.isNote() ? this.getSource() : null;
|
||||||
var noteText = this._noteText ? this._noteText : '';
|
var noteText = this._noteText ? this._noteText : '';
|
||||||
// Add <div> wrapper if not present
|
// 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>';
|
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 parent = this.isNote() ? this.getSource() : null;
|
||||||
var noteText = this._noteText;
|
var noteText = this._noteText;
|
||||||
// Add <div> wrapper if not present
|
// 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>';
|
noteText = '<div class="zotero-note znv1">' + noteText + '</div>';
|
||||||
}
|
}
|
||||||
var bindParams = [
|
var bindParams = [
|
||||||
|
@ -1994,8 +1994,22 @@ Zotero.Item.prototype.getNote = function() {
|
||||||
|
|
||||||
var sql = "SELECT note FROM itemNotes WHERE itemID=?";
|
var sql = "SELECT note FROM itemNotes WHERE itemID=?";
|
||||||
var note = Zotero.DB.valueQuery(sql, this.id);
|
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
|
// 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 : '';
|
this._noteText = note ? note : '';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user