Changes for note insertion in non-GoogleDocs

This commit is contained in:
Adomas Venčkauskas 2020-10-12 17:01:24 +03:00 committed by Dan Stillman
parent 8709ddd657
commit 51db52a5ea
2 changed files with 8 additions and 11 deletions

View file

@ -586,10 +586,7 @@ Zotero.Integration.Interface.prototype.addEditCitation = async function (docFiel
await this._session.init(false, false);
docField = docField || await this._doc.cursorInField(this._session.data.prefs['fieldType']);
let citations = await this._session.cite(docField);
for (let citation of citations) {
await this._session.addCitation(citation._fieldIndex, await citation._field.getNoteIndex(), citation);
}
await this._session.cite(docField);
if (this._session.data.prefs.delayCitationUpdates) {
for (let citation of citations) {
await this._session.writeDelayedCitation(citation._field, citation);
@ -1447,11 +1444,9 @@ Zotero.Integration.Session.prototype._processNote = function (item) {
Zotero.logError(e);
}
}
// TODO: Later we'll need to convert note HTML to RDF.
// if (Zotero.Integration.currentSession._app.outputFormat == 'rtf') {
// text = return Zotero.RTFConverter.HTMLToRTF(text);
// });
// }
text = text.replace(/[\u00A0-\u9999\&]/gim, function(i) {
return '&#'+i.charCodeAt(0)+';';
});
return [text, citations, placeholderIDs];
};
@ -1465,7 +1460,7 @@ Zotero.Integration.Session.prototype._insertNoteIntoDocument = async function (f
citations.reverse();
placeholderIDs.reverse();
let fields = await this._doc.convertPlaceholdersToFields(citations.map(() => 'TEMP'),
placeholderIDs, this.data.prefs.noteType);
placeholderIDs, this.data.prefs.noteType, this.data.prefs.fieldType);
let insertedCitations = await Promise.all(fields.map(async (field, index) => {
let citation = new Zotero.Integration.Citation(new Zotero.Integration.CitationField(field, 'TEMP'),

View file

@ -110,10 +110,12 @@ describe("Zotero.Integration", function () {
* 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 {String[]} placeholderIDs - the order of placeholders to be replaced
* @param {Number} noteType - controls whether citations should be in-text or in footnotes/endnotes
* @param {Number} fieldType
* @return {Field[]}
*/
convertPlaceholdersToFields: function (codes, noteType) {
convertPlaceholdersToFields: function (codes, placeholderIDs, noteType, fieldType) {
return codes.map(code => {
let field = new DocumentPluginDummy.Field(this);
field.code = code;