- update rich text interface to support subscript, superscript, and RTF indents
- cancel button works in edit citation dialog, and has been removed from edit bibliography dialog
This commit is contained in:
parent
9a40d041b3
commit
7fef8f9a3c
|
@ -38,21 +38,32 @@
|
|||
this._buttons = {
|
||||
'italic':document.getAnonymousElementByAttribute(this, "anonid", "rt-italic"),
|
||||
'bold':document.getAnonymousElementByAttribute(this, "anonid", "rt-bold"),
|
||||
'underline':document.getAnonymousElementByAttribute(this, "anonid", "rt-underline")
|
||||
'underline':document.getAnonymousElementByAttribute(this, "anonid", "rt-underline"),
|
||||
'superscript':document.getAnonymousElementByAttribute(this, "anonid", "rt-superscript"),
|
||||
'subscript':document.getAnonymousElementByAttribute(this, "anonid", "rt-subscript")
|
||||
};
|
||||
|
||||
// globals
|
||||
this._formatMap = {
|
||||
"Integration":{
|
||||
"\\":"\\\\",
|
||||
"&":"&",
|
||||
"<":"<",
|
||||
">":">",
|
||||
"<i>":"\\i ",
|
||||
"</i>":"\\i0 ",
|
||||
"<b>":"\\b ",
|
||||
"</b>":"\\b0 ",
|
||||
"<u>":"\\ul ",
|
||||
"</u>":"\\ul0 ",
|
||||
"<br>":"\n",
|
||||
"&":"&"
|
||||
"<br>":"\x0B",
|
||||
"<sup>":"\\super ",
|
||||
"</sup>":"\\super0 ",
|
||||
"<sub>":"\\sub ",
|
||||
"</sub>":"\\sub0 ",
|
||||
// there's no way to mimic a tab stop in CSS without
|
||||
// tables, which wouldn't work here.
|
||||
'<span class="tab"> </span>':"\t"
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -114,7 +125,7 @@
|
|||
<!-- Updates the status of text toggle buttons -->
|
||||
<method name="_updateButtons">
|
||||
<body><![CDATA[
|
||||
for each(var command in ["bold", "italic", "underline"]) {
|
||||
for each(var command in ["bold", "italic", "underline", "superscript", "subscript"]) {
|
||||
try {
|
||||
var enabled = this._browser.contentDocument.queryCommandState(command);
|
||||
|
||||
|
@ -193,7 +204,38 @@
|
|||
<setter><![CDATA[
|
||||
if(this._isLoaded) {
|
||||
var html = val;
|
||||
bodyStyle = "";
|
||||
if(this._format != "HTML") {
|
||||
if(this._format == "Integration") {
|
||||
if(html.substr(0, 3) == "\\li") {
|
||||
// try to show paragraph formatting
|
||||
var returnIndex = html.indexOf("\r\n");
|
||||
|
||||
var tags = html.substr(1, returnIndex).split("\\");
|
||||
html = html.substr(returnIndex+2);
|
||||
|
||||
for(var i=0; i<tags.length; i++) {
|
||||
var tagName = tags[i].substr(0, 2);
|
||||
var tagValue = tags[i].substring(2, tags[i].length-1);
|
||||
if(tagName == "li") {
|
||||
var li = parseInt(tagValue, 10);
|
||||
} else if(tagName == "fi") {
|
||||
var fi = parseInt(tagValue, 10);
|
||||
}
|
||||
}
|
||||
|
||||
// don't negatively indent
|
||||
Zotero.debug(li);
|
||||
Zotero.debug(fi);
|
||||
if(fi < 0 && li == 0) {
|
||||
li = -fi;
|
||||
}
|
||||
|
||||
bodyStyle = "margin-left:"+(li/20+6)+"pt;text-indent:"+(fi/20)+"pt;";
|
||||
Zotero.debug(bodyStyle);
|
||||
}
|
||||
}
|
||||
|
||||
// do appropriate replacement operations for non-HTML
|
||||
// formats
|
||||
var replacements = this._formatMap[this._format];
|
||||
|
@ -203,7 +245,7 @@
|
|||
}
|
||||
|
||||
// write
|
||||
this._browser.contentDocument.write("<body>"+html+"</body>");
|
||||
this._browser.contentDocument.write('<body style="'+bodyStyle+'">'+html+"</body>");
|
||||
this._browser.contentDocument.close();
|
||||
this._browser.contentDocument.designMode = (this._readonly ? "off" : "on");
|
||||
try {
|
||||
|
@ -235,6 +277,12 @@
|
|||
<xul:toolbarbutton anonid="rt-underline" class="rt-underline rt-text-control"
|
||||
tooltiptext="&zotero.richText.underline.label;"
|
||||
oncommand="parentNode.parentNode.parentNode.toggle('underline');"/>
|
||||
<xul:toolbarbutton anonid="rt-superscript" class="rt-superscript rt-text-control"
|
||||
tooltiptext="&zotero.richText.superscript.label;"
|
||||
oncommand="parentNode.parentNode.parentNode.toggle('superscript');"/>
|
||||
<xul:toolbarbutton anonid="rt-subscript" class="rt-subscript rt-text-control"
|
||||
tooltiptext="&zotero.richText.subscript.label;"
|
||||
oncommand="parentNode.parentNode.parentNode.toggle('subscript');"/>
|
||||
</xul:toolbar>
|
||||
|
||||
<xul:browser flex="1" anonid="rt-view" class="rt-view"
|
||||
|
|
|
@ -1418,6 +1418,30 @@ Zotero.CSL.Citation.prototype.remove = function(citationItems) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* copies a citation
|
||||
*/
|
||||
Zotero.CSL.Citation.prototype.clone = function() {
|
||||
var clone = new Zotero.CSL.Citation();
|
||||
|
||||
// copy items
|
||||
for(var i=0; i<this.citationItems.length; i++) {
|
||||
var oldCitationItem = this.citationItems[i];
|
||||
var newCitationItem = new Zotero.CSL.CitationItem();
|
||||
for(var key in oldCitationItem) {
|
||||
newCitationItem[key] = oldCitationItem[key];
|
||||
}
|
||||
clone.citationItems.push(newCitationItem);
|
||||
}
|
||||
|
||||
// copy properties
|
||||
for(var key in this.properties) {
|
||||
clone.properties[key] = this.properties[key];
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is an item wrapper class for Zotero items. If converting this code to
|
||||
* work with another application, this is what needs changing. Potentially, this
|
||||
|
|
|
@ -773,7 +773,7 @@ Zotero.Integration.Session.prototype.editCitation = function(index, citation) {
|
|||
var io = new function() { this.wrappedJSObject = this; }
|
||||
|
||||
// create object to hold citation
|
||||
io.citation = (citation ? citation : this.style.createCitation());
|
||||
io.citation = (citation ? citation.clone() : this.style.createCitation());
|
||||
io.citation.properties.index = index;
|
||||
// assign preview function
|
||||
io.previewFunction = function() {
|
||||
|
@ -784,7 +784,11 @@ Zotero.Integration.Session.prototype.editCitation = function(index, citation) {
|
|||
.getService(Components.interfaces.nsIWindowWatcher)
|
||||
.openWindow(null, 'chrome://zotero/content/addCitationDialog.xul', '',
|
||||
'chrome,modal'+(Zotero.isWin ? ',popup' : ''), io);
|
||||
|
||||
|
||||
if(citation && !io.citation.citationItems.length) {
|
||||
io.citation = citation;
|
||||
}
|
||||
|
||||
if(io.citation.citationItems.length) { // we have an item
|
||||
this.addCitation(index, io.citation);
|
||||
this.updateIndices[index] = true;
|
||||
|
|
|
@ -130,6 +130,8 @@
|
|||
<!ENTITY zotero.richText.italic.label "Italic">
|
||||
<!ENTITY zotero.richText.bold.label "Bold">
|
||||
<!ENTITY zotero.richText.underline.label "Underline">
|
||||
<!ENTITY zotero.richText.superscript.label "Superscript">
|
||||
<!ENTITY zotero.richText.subscript.label "Subscript">
|
||||
|
||||
<!ENTITY zotero.annotate.toolbar.add.label "Add Annotation">
|
||||
<!ENTITY zotero.annotate.toolbar.collapse.label "Collapse All Annotations">
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
list-style-image: url('chrome://zotero/skin/text_underline.png');
|
||||
}
|
||||
|
||||
.rt-superscript {
|
||||
list-style-image: url('chrome://zotero/skin/text_superscript.png');
|
||||
}
|
||||
|
||||
.rt-subscript {
|
||||
list-style-image: url('chrome://zotero/skin/text_subscript.png');
|
||||
}
|
||||
|
||||
.rt-toolbar {
|
||||
padding: 2px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user