Add click image to insert or copy coordinates

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2026-05-25 08:13:53 -07:00
parent 2685e10ae0
commit fb206279a3

View File

@@ -1,4 +1,3 @@
console.log('Previewing Annotation page...')
elSvgCont = document.querySelector('div#svg-wrapper')
elSvg = elSvgCont.childNodes[0]
elCoordBox = document.createElement('div')
@@ -9,7 +8,31 @@ elCoordBox.style.background='#ffffff99'
elCoordBox.style.border='1px solid black'
elSvgCont.appendChild(elCoordBox)
elScale = elSvg.getAttribute('mwscale')
elSvgCont.addEventListener('click', () => {navigator.clipboard.writeText(`[${elCoordBox.textContent}]`)})
elSvgCont.addEventListener('click', (e) => {
e.preventDefault()
console.log(e)
if (!e.ctrlKey) {
elInput = document.getElementById('wpTextbox1')
elInput.setRangeText(`[${elCoordBox.textContent}]`)
elInput.selectionStart += elCoordBox.textContent.length + 2
} else {
navigator.clipboard.writeText(`[${elCoordBox.textContent}]`)
}
})
elSvgCont.addEventListener('contextmenu', (e) => {e.preventDefault()})
elSvgCont.addEventListener('auxclick', (e) => {
e.preventDefault()
console.log(e)
if (!e.ctrlKey) {
elInput = document.getElementById('wpTextbox1')
elInput.setRangeText(` ${elCoordBox.textContent.replace(',','')}`)
elInput.selectionStart += elCoordBox.textContent.length
} else {
navigator.clipboard.writeText(` ${elCoordBox.textContent.replace(',','')}`)
}
})
elSvgCont.addEventListener('mouseenter', () => {elCoordBox.style.display='block'})
elSvgCont.addEventListener('mouseleave', () => {elCoordBox.style.display='none'})
elSvgCont.addEventListener('mousemove',(e) => {