Add click image to insert or copy coordinates
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
console.log('Previewing Annotation page...')
|
|
||||||
elSvgCont = document.querySelector('div#svg-wrapper')
|
elSvgCont = document.querySelector('div#svg-wrapper')
|
||||||
elSvg = elSvgCont.childNodes[0]
|
elSvg = elSvgCont.childNodes[0]
|
||||||
elCoordBox = document.createElement('div')
|
elCoordBox = document.createElement('div')
|
||||||
@@ -9,7 +8,31 @@ elCoordBox.style.background='#ffffff99'
|
|||||||
elCoordBox.style.border='1px solid black'
|
elCoordBox.style.border='1px solid black'
|
||||||
elSvgCont.appendChild(elCoordBox)
|
elSvgCont.appendChild(elCoordBox)
|
||||||
elScale = elSvg.getAttribute('mwscale')
|
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('mouseenter', () => {elCoordBox.style.display='block'})
|
||||||
elSvgCont.addEventListener('mouseleave', () => {elCoordBox.style.display='none'})
|
elSvgCont.addEventListener('mouseleave', () => {elCoordBox.style.display='none'})
|
||||||
elSvgCont.addEventListener('mousemove',(e) => {
|
elSvgCont.addEventListener('mousemove',(e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user