commit 55bfe54af2bbf90f52dd4541cad92f6b8e99dcb6
parent d60da717c4206ed8b7149af50bd178dda6ec015f
Author: fbennett <biercenator@gmail.com>
Date: Sat, 2 Apr 2016 12:02:53 +0900
Bugfixes for new styled-textbox code
Diffstat:
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml
@@ -52,19 +52,11 @@
this._htmlRTFmap = [
// Atomic units, HTML -> RTF (cleanup)
[/<br \/>/g, "\x0B"],
- [/<span class=\"tab\"> <\/span>/g, "\\tab{}"],
- [/‘/g, "‘"],
- [/’/g, "’"],
- [/“/g, "“"],
- [/”/g, "”"],
- [/ /g, "\u00A0"],
[/"(\w)/g, "“$1"],
[/([\w,.?!])"/g, "$1”"],
[/<p>/g, ""],
//[/<\/p>(?!\s*$)/g, "\\par{}"],
[/<\/?div[^>]*>/g, ""],
- //[/ /g, " "],
- //[/\u00A0/g, " "],
[/[\x7F-\uFFFF]/g, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}"}]
];
@@ -343,12 +335,14 @@
}
this.htmlToRTF = function(txt) {
- txt = this.convert("htmlRTF", txt);
+ // Catch this one before is clobbered by unescape
+ txt = txt.replace(/<span class=\"tab\"> <\/span>/g, "\\tab{}");
+ txt = Zotero.Utilities.unescapeHTML(txt);
for (var i=0,ilen=this._htmlRTFmap.length; i < ilen; i++) {
var entry = this._htmlRTFmap[i];
txt = txt.replace(entry[0], entry[1]);
}
- txt = Zotero.Utilities.unescapeHTML(txt);
+ txt = this.convert("htmlRTF", txt);
return txt.trim();
}
@@ -358,7 +352,7 @@
txt = txt.replace(entry[0], entry[1]);
}
txt = this.convert("rtfHTML", txt);
- return txt;
+ return txt.trim();
}
this._constructed = true;
@@ -473,12 +467,12 @@
<!-- Sets or returns contents of rich text box -->
<property name="value">
<getter><![CDATA[
- var output = this._editor.getContent();
+ var output = this._editor.getContent().trim();
if(this._format == "RTF") {
// strip divs
if(output.substr(0, 5) == "<div>" && output.substr(-6) == "</div>") {
- output = output.substr(5, output.length-6);
+ output = output.slice(0, output.length-6).slice(5).trim();
}
output = this.htmlToRTF(output)
}