Add support for underline annotations
(cherry picked from commit cb14034c46
)
This commit is contained in:
parent
4f7583e1c0
commit
0ad55a6a70
3 changed files with 12 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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 || '';
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue