Instantate CSL processor once on drag, changing output mode on the fly
This commit is contained in:
parent
5bfc1e4199
commit
523724185c
|
@ -419,9 +419,10 @@ var Zotero_File_Interface = new function() {
|
||||||
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
|
var clipboardService = Components.classes["@mozilla.org/widget/clipboard;1"].
|
||||||
getService(Components.interfaces.nsIClipboard);
|
getService(Components.interfaces.nsIClipboard);
|
||||||
var style = Zotero.Styles.get(style);
|
var style = Zotero.Styles.get(style);
|
||||||
|
var cslEngine = style.getCiteProc();
|
||||||
|
|
||||||
// add HTML
|
// add HTML
|
||||||
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "html", asCitations);
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html", asCitations);
|
||||||
var str = Components.classes["@mozilla.org/supports-string;1"].
|
var str = Components.classes["@mozilla.org/supports-string;1"].
|
||||||
createInstance(Components.interfaces.nsISupportsString);
|
createInstance(Components.interfaces.nsISupportsString);
|
||||||
str.data = bibliography;
|
str.data = bibliography;
|
||||||
|
@ -430,7 +431,7 @@ var Zotero_File_Interface = new function() {
|
||||||
|
|
||||||
// add text (or HTML source)
|
// add text (or HTML source)
|
||||||
if(!asHTML) {
|
if(!asHTML) {
|
||||||
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "text", asCitations);
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text", asCitations);
|
||||||
}
|
}
|
||||||
var str = Components.classes["@mozilla.org/supports-string;1"].
|
var str = Components.classes["@mozilla.org/supports-string;1"].
|
||||||
createInstance(Components.interfaces.nsISupportsString);
|
createInstance(Components.interfaces.nsISupportsString);
|
||||||
|
@ -516,7 +517,8 @@ var Zotero_File_Interface = new function() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var style = Zotero.Styles.get(io.style);
|
var style = Zotero.Styles.get(io.style);
|
||||||
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style,
|
var cslEngine = style.getCiteProc();
|
||||||
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine,
|
||||||
items, format, io.mode === "citations");
|
items, format, io.mode === "citations");
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
|
@ -71,8 +71,7 @@ Zotero.Cite = {
|
||||||
* @param {String} format The format of the output (html, text, or rtf)
|
* @param {String} format The format of the output (html, text, or rtf)
|
||||||
* @return {String} Bibliography or item list in specified format
|
* @return {String} Bibliography or item list in specified format
|
||||||
*/
|
*/
|
||||||
"makeFormattedBibliographyOrCitationList":function(style, items, format, asCitationList) {
|
"makeFormattedBibliographyOrCitationList":function(cslEngine, items, format, asCitationList) {
|
||||||
var cslEngine = style.getCiteProc();
|
|
||||||
cslEngine.setOutputFormat(format);
|
cslEngine.setOutputFormat(format);
|
||||||
cslEngine.updateItems([item.id for each(item in items)]);
|
cslEngine.updateItems([item.id for each(item in items)]);
|
||||||
|
|
||||||
|
|
|
@ -337,8 +337,9 @@ Zotero.QuickCopy = new function() {
|
||||||
var text = csl.previewCitationCluster(citation, [], [], "text");
|
var text = csl.previewCitationCluster(citation, [], [], "text");
|
||||||
} else {
|
} else {
|
||||||
var style = Zotero.Styles.get(format);
|
var style = Zotero.Styles.get(format);
|
||||||
var html = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "html");
|
var cslEngine = style.getCiteProc();
|
||||||
var text = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "text");
|
var html = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html");
|
||||||
|
var text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {text:(contentType == "html" ? html : text), html:html};
|
return {text:(contentType == "html" ? html : text), html:html};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user