From 974a07bf73370eeac43847c211fd9f652935b817 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 24 Sep 2015 23:44:19 -0400 Subject: [PATCH] Add addEditCitation command to Zotero --- chrome/content/zotero/xpcom/integration.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 4d2bd83102..106ab228da 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1042,7 +1042,7 @@ Zotero.Integration.Document.prototype.addCitation = function() { return (new Zotero.Integration.Fields(me._session, me._doc)).addEditCitation(null); }); } - + /** * Edits the citation at the cursor position. * @return {Promise} @@ -1050,7 +1050,7 @@ Zotero.Integration.Document.prototype.addCitation = function() { Zotero.Integration.Document.prototype.editCitation = function() { var me = this; return this._getSession(true, false).then(function() { - var field = me._doc.cursorInField(me._session.data.prefs['fieldType']) + var field = me._doc.cursorInField(me._session.data.prefs['fieldType']); if(!field) { throw new Zotero.Exception.Alert("integration.error.notInCitation", [], "integration.error.title"); @@ -1060,6 +1060,18 @@ Zotero.Integration.Document.prototype.editCitation = function() { }); } +/** + * Edits the citation at the cursor position if one exists, or else adds a new one. + * @return {Promise} + */ +Zotero.Integration.Document.prototype.addEditCitation = function() { + var me = this; + return this._getSession(false, false).then(function() { + var field = me._doc.cursorInField(me._session.data.prefs['fieldType']); + return (new Zotero.Integration.Fields(me._session, me._doc)).addEditCitation(field); + }); +} + /** * Adds a bibliography to the current document. * @return {Promise}