From 837b37f6639d7e57b768ad7b7ffc612b14c4a3c3 Mon Sep 17 00:00:00 2001 From: Wolfgang Meier Date: Mon, 22 Jan 2024 12:11:31 +0100 Subject: [PATCH] fix(pb-view-annotate): changes not saved after editing/correcting an added (but not yet merged) annotation --- src/pb-view-annotate.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pb-view-annotate.js b/src/pb-view-annotate.js index ddea163d..5a5159f9 100644 --- a/src/pb-view-annotate.js +++ b/src/pb-view-annotate.js @@ -677,16 +677,7 @@ class PbViewAnnotate extends PbView { } editAnnotation(span, properties) { - if (span.dataset.type === 'edit') { - let range = this._rangesMap.get(span); - if (range) { - range.properties = properties; - range = clearProperties(range); - this.emitTo('pb-annotations-changed', { ranges: this._ranges }); - } else { - console.error('no range found for edit span %o', span); - } - } else if (span.dataset.tei) { + if (span.dataset.tei) { // TODO: check in _ranges if it has already been modified const context = span.closest('[data-tei]'); let range = this._ranges.find(r => r.type === 'modify' && r.node === span.dataset.tei); @@ -701,6 +692,15 @@ class PbViewAnnotate extends PbView { range.properties = properties; range = clearProperties(range); this.emitTo('pb-annotations-changed', { ranges: this._ranges }); + } else { + let range = this._rangesMap.get(span); + if (range) { + range.properties = properties; + range = clearProperties(range); + this.emitTo('pb-annotations-changed', { ranges: this._ranges }); + } else { + console.error('no range found for edit span %o', span); + } } const jsonOld = JSON.parse(span.dataset.annotation); const json = Object.assign(jsonOld || {}, properties);