Add ability to cite Zotero notes.

<span class=citation data-citation=serialized-citation-data/>
elements will automatically be converted to zotero citations
This commit is contained in:
Adomas Venčkauskas 2020-09-25 15:26:02 +03:00 committed by Dan Stillman
parent 2b3669afd8
commit 2e9e655479
7 changed files with 325 additions and 124 deletions

View file

@ -21,7 +21,10 @@ describe("Zotero.Integration", function () {
this.primaryFieldType = "Field";
this.secondaryFieldType = "Bookmark";
this.supportedNotes = ['footnotes', 'endnotes'];
// Will display an option to switch word processors in the Doc Prefs
this.supportsImportExport = true;
// Will allow inserting notes
this.supportsTextInsertion = true;
this.fields = [];
};
DocumentPluginDummy.Application.prototype = {
@ -82,25 +85,48 @@ describe("Zotero.Integration", function () {
*/
setDocumentData: function(data) {this.data = data},
/**
* Inserts a field at the given position and initializes the field object.
* Inserts a field at cursor position and initializes the field object.
* If Document.insertText() was called previously inserts the field
* directly after the inserted text.
* @param {String} fieldType
* @param {Integer} noteType
* @returns {DocumentPluginDummy.Field}
*/
insertField: function(fieldType, noteType) {
insertField: function(fieldType, noteType) {
if (typeof noteType != "number") {
throw new Error("noteType must be an integer");
}
var field = new DocumentPluginDummy.Field(this);
var field = new DocumentPluginDummy.Field(this);
this.fields.push(field);
return field;
},
/**
* Inserts rich text at cursor position. If Document.insertField() was called
* previously inserts the text directly after the inserted field.
* @param {String} text
*/
insertText: function (text) { return; },
/**
* Converts placeholders (which are text with links to https://www.zotero.org/?[placeholderID])
* to fields and sets their field codes to strings in `codes` in the reverse order of their appearance
* @param {String[]} codes
* @param {Number} noteType - controls whether citations should be in-text or in footnotes/endnotes
* @return {Field[]}
*/
convertPlaceholdersToFields: function (codes, noteType) {
return codes.map(code => {
let field = new DocumentPluginDummy.Field(this);
field.code = code;
this.fields.push(field);
return field;
});
},
/**
* Gets all fields present in the document.
* @param {String} fieldType
* @returns {DocumentPluginDummy.Field[]}
*/
getFields: function(fieldType) {return Array.from(this.fields)},
getFields: function (fieldType) {return Array.from(this.fields)},
/**
* Sets the bibliography style, overwriting the current values for this document
*/