mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
use mousedown instead of click event to fix double caret
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
this.cm = cm
|
this.cm = cm
|
||||||
this.lineDiv = cm.display.lineDiv
|
this.lineDiv = cm.display.lineDiv
|
||||||
|
|
||||||
this.onClick = this.onClick.bind(this)
|
this.onMouseDown = this.onMouseDown.bind(this)
|
||||||
this.onMouseEnter = this.onMouseEnter.bind(this)
|
this.onMouseEnter = this.onMouseEnter.bind(this)
|
||||||
this.onMouseLeave = this.onMouseLeave.bind(this)
|
this.onMouseLeave = this.onMouseLeave.bind(this)
|
||||||
this.onMouseMove = this.onMouseMove.bind(this)
|
this.onMouseMove = this.onMouseMove.bind(this)
|
||||||
@@ -31,10 +31,18 @@
|
|||||||
this.tooltip.appendChild(this.tooltipIndicator)
|
this.tooltip.appendChild(this.tooltipIndicator)
|
||||||
this.tooltipContent.textContent = 'Cmd + click to follow link'
|
this.tooltipContent.textContent = 'Cmd + click to follow link'
|
||||||
|
|
||||||
this.lineDiv.addEventListener('click', this.onClick, true)
|
this.lineDiv.addEventListener('mousedown', this.onMouseDown)
|
||||||
this.lineDiv.addEventListener('mouseenter', this.onMouseEnter, true)
|
this.lineDiv.addEventListener('mouseenter', this.onMouseEnter, {
|
||||||
this.lineDiv.addEventListener('mouseleave', this.onMouseLeave, true)
|
capture: true,
|
||||||
this.lineDiv.addEventListener('mousemove', this.onMouseMove, true)
|
passive: true
|
||||||
|
})
|
||||||
|
this.lineDiv.addEventListener('mouseleave', this.onMouseLeave, {
|
||||||
|
capture: true,
|
||||||
|
passive: true
|
||||||
|
})
|
||||||
|
this.lineDiv.addEventListener('mousemove', this.onMouseMove, {
|
||||||
|
passive: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
getUrl(el) {
|
getUrl(el) {
|
||||||
const className = el.className.split(' ')
|
const className = el.className.split(' ')
|
||||||
@@ -46,7 +54,7 @@
|
|||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
onClick(e) {
|
onMouseDown(e) {
|
||||||
const { target, metaKey } = e
|
const { target, metaKey } = e
|
||||||
if (!metaKey) {
|
if (!metaKey) {
|
||||||
return
|
return
|
||||||
@@ -55,7 +63,6 @@
|
|||||||
const url = this.getUrl(target)
|
const url = this.getUrl(target)
|
||||||
if (url) {
|
if (url) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
|
||||||
|
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user