Fix conversion regex

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2026-06-09 17:18:56 -07:00
parent 6410d355ee
commit bb5235727a

View File

@@ -26,8 +26,8 @@ elSvgCont.addEventListener('auxclick', (e) => {
console.log(e)
if (!e.ctrlKey) {
elInput = document.getElementById('wpTextbox1')
elInput.setRangeText(` ${elCoordBox.textContent.replace(',','')}`)
elInput.selectionStart += elCoordBox.textContent.length
elInput.setRangeText(`${(e.altKey ? ' S' : ' ')}${elCoordBox.textContent.replace(',','')}`)
elInput.selectionStart += elCoordBox.textContent.length + (e.altKey ? 1 : 0)
} else {
navigator.clipboard.writeText(` ${elCoordBox.textContent.replace(',','')}`)
}
@@ -43,14 +43,14 @@ elSvgCont.addEventListener('mousemove',(e) => {
elCoordBox.style.top = e.offsetY + 12
})
document.addEventListener('keydown',(e) => {
if (e.altKey && e.shiftKey && !e.ctrlKey && e.key == "C") {
coordParse = /(\[?)([0-9]+)\s?,\s?([0-9]+)(\]?)/
if (e.altKey && !e.shiftKey && !e.ctrlKey && e.key == "F3") {
coordParse = /(\[?)([\d\.]+)(,|(?:,\s)|\s)\D*([\d\.]+)(\]?)/
oldCoord = coordParse.exec(window.getSelection().toString())
if (oldCoord) {
calcX = (oldCoord[2] / 100 * elSvg.width.baseVal.value / elScale).toFixed(1)
calcY = (oldCoord[3] / 100 * elSvg.height.baseVal.value / elScale).toFixed(1)
calcY = (oldCoord[4] / 100 * elSvg.height.baseVal.value / elScale).toFixed(1)
elInput = document.getElementById('wpTextbox1')
elInput.setRangeText(`${oldCoord[1]}${calcX}, ${calcY}${oldCoord[4]}`)
elInput.setRangeText(`${oldCoord[1]}${calcX}${oldCoord[3]}${calcY}${oldCoord[5]}`)
}
}
})