diff --git a/modules/annot-prev.js b/modules/annot-prev.js index e29ca31..cc3c500 100644 --- a/modules/annot-prev.js +++ b/modules/annot-prev.js @@ -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]}`) } } }) \ No newline at end of file