Enable type change between highlight and underline (#4411)

This commit is contained in:
Martynas Bagdonas 2024-07-20 09:27:11 +03:00 committed by GitHub
parent e20e62d4f7
commit d16ea8fe15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -3947,8 +3947,10 @@ for (let name of ['type', 'authorName', 'text', 'comment', 'color', 'pageLabel',
switch (name) {
case 'type': {
let currentType = this._getLatestField('annotationType');
if (currentType && currentType != value) {
throw new Error("Cannot change annotation type");
if (currentType && currentType != value
&& (!['highlight', 'underline'].includes(value)
|| !['highlight', 'underline'].includes(currentType))) {
throw new Error("Only changes between highlight and underline annotation types are permitted");
}
if (!['highlight', 'underline', 'note', 'text', 'image', 'ink'].includes(value)) {
let e = new Error(`Unknown annotation type '${value}'`);

View file

@ -1505,6 +1505,7 @@ describe("Zotero.Item", function () {
var a = new Zotero.Item('annotation');
a.annotationType = 'highlight';
assert.doesNotThrow(() => a.annotationType = 'highlight');
assert.doesNotThrow(() => a.annotationType = 'underline');
assert.throws(() => a.annotationType = 'note');
});
});