feat: copy entire line when cursor is inside

This commit is contained in:
Hufe921
2023-08-31 20:38:16 +08:00
parent abcaa9b51c
commit 3c10be26fb
+6 -6
View File
@@ -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())
}