diff --git a/chrome/content/zotero/xpcom/annotations.js b/chrome/content/zotero/xpcom/annotations.js index cbe5621e35..e5b0137f85 100644 --- a/chrome/content/zotero/xpcom/annotations.js +++ b/chrome/content/zotero/xpcom/annotations.js @@ -32,7 +32,8 @@ Zotero.Annotations = new function () { Zotero.defineProperty(this, 'ANNOTATION_TYPE_NOTE', { value: 2 }); Zotero.defineProperty(this, 'ANNOTATION_TYPE_IMAGE', { value: 3 }); Zotero.defineProperty(this, 'ANNOTATION_TYPE_INK', { value: 4 }); - + Zotero.defineProperty(this, 'ANNOTATION_TYPE_UNDERLINE', { value: 5 }); + Zotero.defineProperty(this, 'DEFAULT_COLOR', { value: '#ffd400' }); Zotero.defineProperty(this, 'PROPS', { @@ -137,7 +138,7 @@ Zotero.Annotations = new function () { } } o.readOnly = o.isExternal || !isAuthor; - if (o.type == 'highlight') { + if (['highlight', 'underline'].includes(o.type)) { o.text = item.annotationText; } else if (['image', 'ink'].includes(o.type)) { @@ -213,7 +214,7 @@ Zotero.Annotations = new function () { item._requireData('annotationDeferred'); item.annotationType = json.type; item.annotationAuthorName = json.authorName || ''; - if (json.type == 'highlight') { + if (['highlight', 'underline'].includes(json.type)) { item.annotationText = json.text; } item.annotationIsExternal = !!json.isExternal; diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index de3235d635..8f6deecbbf 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3815,7 +3815,7 @@ for (let name of ['type', 'authorName', 'text', 'comment', 'color', 'pageLabel', if (currentType && currentType != value) { throw new Error("Cannot change annotation type"); } - if (!['highlight', 'note', 'image', 'ink'].includes(value)) { + if (!['highlight', 'underline', 'note', 'image', 'ink'].includes(value)) { let e = new Error(`Unknown annotation type '${value}'`); e.name = "ZoteroInvalidDataError"; throw e; @@ -3823,8 +3823,8 @@ for (let name of ['type', 'authorName', 'text', 'comment', 'color', 'pageLabel', break; } case 'text': - if (this._getLatestField('annotationType') != 'highlight') { - throw new Error("'annotationText' can only be set for highlight annotations"); + if (!['highlight', 'underline'].includes(this._getLatestField('annotationType'))) { + throw new Error("'annotationText' can only be set for highlight and underline annotations"); } break; @@ -5047,7 +5047,6 @@ Zotero.Item.prototype.fromJSON = function (json, options = {}) { // Annotation fields // case 'annotationType': - case 'annotationType': case 'annotationAuthorName': case 'annotationText': case 'annotationComment': @@ -5326,7 +5325,7 @@ Zotero.Item.prototype.toJSON = function (options = {}) { let type = this.annotationType; obj.annotationType = type; obj.annotationAuthorName = this.annotationAuthorName || ''; - if (type == 'highlight') { + if (['highlight', 'underline'].includes(type)) { obj.annotationText = this.annotationText || ''; } obj.annotationComment = this.annotationComment || ''; diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 8fc1e13417..a8513bc2df 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -524,6 +524,10 @@ Zotero.Items = function() { case Zotero.Annotations.ANNOTATION_TYPE_HIGHLIGHT: type = 'highlight'; break; + + case Zotero.Annotations.ANNOTATION_TYPE_UNDERLINE: + type = 'underline'; + break; case Zotero.Annotations.ANNOTATION_TYPE_NOTE: type = 'note';