diff --git a/bms-front/src/directive/common/textDragCopy.js b/bms-front/src/directive/common/textDragCopy.js index ea221025..00a55684 100644 --- a/bms-front/src/directive/common/textDragCopy.js +++ b/bms-front/src/directive/common/textDragCopy.js @@ -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