Enable type change between highlight and underline (#4411)
This commit is contained in:
parent
e20e62d4f7
commit
d16ea8fe15
2 changed files with 5 additions and 2 deletions
|
@ -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}'`);
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue