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
|
deleteHotspot = null
|
||||||
enableViewer()
|
enableViewer()
|
||||||
const anName = hs.target.childNodes[0].innerText
|
const anName = hs.target.childNodes[0].innerText
|
||||||
let purgeAnnotation = new RegExp('(?<="annotationSets"[\\S\\s]*?)(^.*?' + anName + '.*\n)','gm')
|
|
||||||
hs.target.remove()
|
hs.target.remove()
|
||||||
const editText = $('#wpTextbox1').val()
|
let currentText = $('#wpTextbox1').val()
|
||||||
const newText = editText.replace(purgeAnnotation,'')
|
let [_, mvconfig] = extractMvconfig(currentText)
|
||||||
const finalText = newText.replace(/(,)(\n\s+])/gm,'$2')
|
delete mvconfig.annotations[anName]
|
||||||
$('#wpTextbox1').val(finalText)
|
for (anSet in mvconfig.annotationSets) {
|
||||||
writeMvconfig()
|
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()
|
readMvconfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user