feat: copy entire line when cursor is inside
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user