commit 09a859d7e3c0fabf7377bf93a9b36baab14c40f6 parent 3715c8da1b0688f7acc5247deab21df54e730a87 Author: Dan Stillman <dstillman@zotero.org> Date: Tue, 18 Jul 2017 17:14:20 -0400 Allow an array of strings in Zotero.Item::setTags() New tags will all be of type 0 (manual) Diffstat:
| M | chrome/content/zotero/xpcom/data/item.js | | | 7 | +++++-- |
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -3372,11 +3372,14 @@ Zotero.Item.prototype.getTagType = function (tagName) { * * A separate save() is required to update the database. * - * @param {Array} tags Tag data in API JSON format (e.g., [{tag: 'tag', type: 1}]) + * @param {String[]|Object[]} tags - Array of strings or object in API JSON format + * (e.g., [{tag: 'tag', type: 1}]) */ Zotero.Item.prototype.setTags = function (tags) { var oldTags = this.getTags(); - var newTags = tags.concat(); + var newTags = tags.concat() + // Allow array of strings + .map(tag => typeof tag == 'string' ? { tag } : tag); for (let i=0; i<oldTags.length; i++) { oldTags[i] = Zotero.Tags.cleanData(oldTags[i]); }