diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 772fee8d8..9ab5a1e21 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1130,7 +1130,7 @@ Zotero.Integration.Fields.prototype.addEditCitation = Zotero.Promise.coroutine(f if (fields[i].equals(field._field)) { // This is needed, because LibreOffice integration plugin caches the field code instead of asking // the document every time when calling #getCode(). - field._field = fields[i]; + field = new Zotero.Integration.CitationField(fields[i]); return i; } } @@ -1967,10 +1967,9 @@ Zotero.Integration.Field = class { if (field instanceof Zotero.Integration.Field) { throw new Error("Trying to instantiate Integration.Field with Integration.Field, not doc field"); } - // This is not the best solution in terms of performance - for (let prop in field) { - if (prop[0] != '_' && !(prop in this)) { - this[prop] = field[prop].bind ? field[prop].bind(field) : field[prop]; + for (let func of Zotero.Integration.Field.INTERFACE) { + if (!(func in this)) { + this[func] = field[func].bind(field); } } this._field = field; @@ -2018,6 +2017,8 @@ Zotero.Integration.Field = class { return isRich; } }; +Zotero.Integration.Field.INTERFACE = ['delete', 'removeCode', 'select', 'setText', + 'getText', 'setCode', 'getCode', 'equals', 'getNoteIndex']; /** * Load existing field in document and return correct instance of field type