Fix conversion regex
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -26,8 +26,8 @@ elSvgCont.addEventListener('auxclick', (e) => {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
if (!e.ctrlKey) {
|
if (!e.ctrlKey) {
|
||||||
elInput = document.getElementById('wpTextbox1')
|
elInput = document.getElementById('wpTextbox1')
|
||||||
elInput.setRangeText(` ${elCoordBox.textContent.replace(',','')}`)
|
elInput.setRangeText(`${(e.altKey ? ' S' : ' ')}${elCoordBox.textContent.replace(',','')}`)
|
||||||
elInput.selectionStart += elCoordBox.textContent.length
|
elInput.selectionStart += elCoordBox.textContent.length + (e.altKey ? 1 : 0)
|
||||||
} else {
|
} else {
|
||||||
navigator.clipboard.writeText(` ${elCoordBox.textContent.replace(',','')}`)
|
navigator.clipboard.writeText(` ${elCoordBox.textContent.replace(',','')}`)
|
||||||
}
|
}
|
||||||
@@ -43,14 +43,14 @@ elSvgCont.addEventListener('mousemove',(e) => {
|
|||||||
elCoordBox.style.top = e.offsetY + 12
|
elCoordBox.style.top = e.offsetY + 12
|
||||||
})
|
})
|
||||||
document.addEventListener('keydown',(e) => {
|
document.addEventListener('keydown',(e) => {
|
||||||
if (e.altKey && e.shiftKey && !e.ctrlKey && e.key == "C") {
|
if (e.altKey && !e.shiftKey && !e.ctrlKey && e.key == "F3") {
|
||||||
coordParse = /(\[?)([0-9]+)\s?,\s?([0-9]+)(\]?)/
|
coordParse = /(\[?)([\d\.]+)(,|(?:,\s)|\s)\D*([\d\.]+)(\]?)/
|
||||||
oldCoord = coordParse.exec(window.getSelection().toString())
|
oldCoord = coordParse.exec(window.getSelection().toString())
|
||||||
if (oldCoord) {
|
if (oldCoord) {
|
||||||
calcX = (oldCoord[2] / 100 * elSvg.width.baseVal.value / elScale).toFixed(1)
|
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 = document.getElementById('wpTextbox1')
|
||||||
elInput.setRangeText(`${oldCoord[1]}${calcX}, ${calcY}${oldCoord[4]}`)
|
elInput.setRangeText(`${oldCoord[1]}${calcX}${oldCoord[3]}${calcY}${oldCoord[5]}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user