Changes for note insertion in non-GoogleDocs
This commit is contained in:
parent
8709ddd657
commit
51db52a5ea
2 changed files with 8 additions and 11 deletions
|
@ -586,10 +586,7 @@ Zotero.Integration.Interface.prototype.addEditCitation = async function (docFiel
|
||||||
await this._session.init(false, false);
|
await this._session.init(false, false);
|
||||||
docField = docField || await this._doc.cursorInField(this._session.data.prefs['fieldType']);
|
docField = docField || await this._doc.cursorInField(this._session.data.prefs['fieldType']);
|
||||||
|
|
||||||
let citations = await this._session.cite(docField);
|
await this._session.cite(docField);
|
||||||
for (let citation of citations) {
|
|
||||||
await this._session.addCitation(citation._fieldIndex, await citation._field.getNoteIndex(), citation);
|
|
||||||
}
|
|
||||||
if (this._session.data.prefs.delayCitationUpdates) {
|
if (this._session.data.prefs.delayCitationUpdates) {
|
||||||
for (let citation of citations) {
|
for (let citation of citations) {
|
||||||
await this._session.writeDelayedCitation(citation._field, citation);
|
await this._session.writeDelayedCitation(citation._field, citation);
|
||||||
|
@ -1447,11 +1444,9 @@ Zotero.Integration.Session.prototype._processNote = function (item) {
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Later we'll need to convert note HTML to RDF.
|
text = text.replace(/[\u00A0-\u9999\&]/gim, function(i) {
|
||||||
// if (Zotero.Integration.currentSession._app.outputFormat == 'rtf') {
|
return '&#'+i.charCodeAt(0)+';';
|
||||||
// text = return Zotero.RTFConverter.HTMLToRTF(text);
|
});
|
||||||
// });
|
|
||||||
// }
|
|
||||||
return [text, citations, placeholderIDs];
|
return [text, citations, placeholderIDs];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1465,7 +1460,7 @@ Zotero.Integration.Session.prototype._insertNoteIntoDocument = async function (f
|
||||||
citations.reverse();
|
citations.reverse();
|
||||||
placeholderIDs.reverse();
|
placeholderIDs.reverse();
|
||||||
let fields = await this._doc.convertPlaceholdersToFields(citations.map(() => 'TEMP'),
|
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 insertedCitations = await Promise.all(fields.map(async (field, index) => {
|
||||||
let citation = new Zotero.Integration.Citation(new Zotero.Integration.CitationField(field, 'TEMP'),
|
let citation = new Zotero.Integration.Citation(new Zotero.Integration.CitationField(field, 'TEMP'),
|
||||||
|
|
|
@ -110,10 +110,12 @@ describe("Zotero.Integration", function () {
|
||||||
* Converts placeholders (which are text with links to https://www.zotero.org/?[placeholderID])
|
* 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
|
* to fields and sets their field codes to strings in `codes` in the reverse order of their appearance
|
||||||
* @param {String[]} codes
|
* @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} noteType - controls whether citations should be in-text or in footnotes/endnotes
|
||||||
|
* @param {Number} fieldType
|
||||||
* @return {Field[]}
|
* @return {Field[]}
|
||||||
*/
|
*/
|
||||||
convertPlaceholdersToFields: function (codes, noteType) {
|
convertPlaceholdersToFields: function (codes, placeholderIDs, noteType, fieldType) {
|
||||||
return codes.map(code => {
|
return codes.map(code => {
|
||||||
let field = new DocumentPluginDummy.Field(this);
|
let field = new DocumentPluginDummy.Field(this);
|
||||||
field.code = code;
|
field.code = code;
|
||||||
|
|
Loading…
Reference in a new issue