From 717ef152f1571793f5b503da11dc905c07805e77 Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Sat, 3 May 2025 20:35:23 -0700 Subject: [PATCH] Fix: Successfully delete final annotation Signed-off-by: Justin Georgi --- modules/glmv-hs.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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() }