✨ 支持双击选中表格单元格文字
This commit is contained in:
@@ -220,6 +220,28 @@ function handleMouseUp() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleDoubleClick(event) {
|
||||
const cell = resolveCell(event.target)
|
||||
if (!cell) return
|
||||
|
||||
const textLength = cellText(cell.cell).length
|
||||
if (!textLength) return
|
||||
|
||||
activeSelection = {
|
||||
context: cell.context,
|
||||
bodyWrapper: cell.bodyWrapper,
|
||||
colIndex: cell.colIndex,
|
||||
anchorRow: cell.rowIndex,
|
||||
focusRow: cell.rowIndex,
|
||||
anchorOffset: 0,
|
||||
focusOffset: textLength
|
||||
}
|
||||
dragging = false
|
||||
hasDragged = false
|
||||
renderHighlight()
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
function handleClick(event) {
|
||||
const root = suppressClickRoot
|
||||
if (!root || !root.contains(event.target)) return
|
||||
@@ -244,6 +266,7 @@ function installListeners() {
|
||||
document.addEventListener('mousedown', handleMouseDown, true)
|
||||
document.addEventListener('mousemove', handleMouseMove)
|
||||
document.addEventListener('mouseup', handleMouseUp)
|
||||
document.addEventListener('dblclick', handleDoubleClick)
|
||||
document.addEventListener('click', handleClick, true)
|
||||
document.addEventListener('copy', handleCopy, true)
|
||||
listenersInstalled = true
|
||||
@@ -254,6 +277,7 @@ function removeListeners() {
|
||||
document.removeEventListener('mousedown', handleMouseDown, true)
|
||||
document.removeEventListener('mousemove', handleMouseMove)
|
||||
document.removeEventListener('mouseup', handleMouseUp)
|
||||
document.removeEventListener('dblclick', handleDoubleClick)
|
||||
document.removeEventListener('click', handleClick, true)
|
||||
document.removeEventListener('copy', handleCopy, true)
|
||||
listenersInstalled = false
|
||||
|
||||
Reference in New Issue
Block a user