Fix: Successfully delete final annotation
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -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(/(.*?<mvconfig>)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${TOML.stringify(mvconfig, null, 2)}\n$2`)
|
||||
$('#wpTextbox1').val(newText)
|
||||
readMvconfig()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user