Add automatic coordinate converstion shortcut
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -42,3 +42,15 @@ elSvgCont.addEventListener('mousemove',(e) => {
|
||||
elCoordBox.style.left = e.offsetX + 6
|
||||
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]+)(\]?)/
|
||||
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)
|
||||
elInput = document.getElementById('wpTextbox1')
|
||||
elInput.setRangeText(`${oldCoord[1]}${calcX}, ${calcY}${oldCoord[4]}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user