diff --git a/modules/glmv-hs.js b/modules/glmv-hs.js index 95c769e..6a8563b 100644 --- a/modules/glmv-hs.js +++ b/modules/glmv-hs.js @@ -69,13 +69,15 @@ clickDeleteHotspot = function (hs) { deleteHotspot = null enableViewer() const anName = hs.target.childNodes[0].innerText - let purgeAnnotation = new RegExp('(?<="annotationSets"[\\S\\s]*?)(^.*?' + anName + '.*\n)','gm') hs.target.remove() - const editText = $('#wpTextbox1').val() - const newText = editText.replace(purgeAnnotation,'') - const finalText = newText.replace(/(,)(\n\s+])/gm,'$2') - $('#wpTextbox1').val(finalText) - writeMvconfig() + let currentText = $('#wpTextbox1').val() + let [_, mvconfig] = extractMvconfig(currentText) + delete mvconfig.annotations[anName] + for (anSet in mvconfig.annotationSets) { + mvconfig.annotationSets[anSet]=mvconfig.annotationSets[anSet].filter( x => x !== anName ) + } + let newText = currentText.replace(/(.*?)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${TOML.stringify(mvconfig, null, 2)}\n$2`) + $('#wpTextbox1').val(newText) readMvconfig() }