feat: copy entire line when cursor is inside

pr675
Hufe921 3 years ago
parent abcaa9b51c
commit 3c10be26fb

@ -4,10 +4,10 @@ import { CanvasEvent } from '../CanvasEvent'
export function copy(host: CanvasEvent) {
const draw = host.getDraw()
const rangeManager = draw.getRange()
const { startIndex, endIndex } = rangeManager.getRange()
if (startIndex !== endIndex) {
const options = draw.getOptions()
const elementList = draw.getElementList()
writeElementList(elementList.slice(startIndex + 1, endIndex + 1), options)
}
// 光标闭合时复制整行
const copyElementList = rangeManager.getIsCollapsed()
? rangeManager.getRangeRowElementList()
: rangeManager.getSelectionElementList()
if (!copyElementList?.length) return
writeElementList(copyElementList, draw.getOptions())
}

Loading…
Cancel
Save