Users should be able to select points (not just lines) (#97)
* update selection datastructure to accomodate more selection metadata * Users should be able to select points (not just lines)
This commit is contained in:
@ -1,15 +1,21 @@
|
||||
import { useStore, Range } from '../useStore'
|
||||
import { useStore, Selection, Selections } from '../useStore'
|
||||
|
||||
export function useSetCursor(sourceRange: Range) {
|
||||
export function useSetCursor(
|
||||
sourceRange: Selection['range'],
|
||||
type: Selection['type'] = 'default'
|
||||
) {
|
||||
const { setCursor, selectionRanges, isShiftDown } = useStore((s) => ({
|
||||
setCursor: s.setCursor,
|
||||
selectionRanges: s.selectionRanges,
|
||||
isShiftDown: s.isShiftDown,
|
||||
}))
|
||||
return () => {
|
||||
const ranges = isShiftDown
|
||||
? [...selectionRanges, sourceRange]
|
||||
: [sourceRange]
|
||||
setCursor(ranges)
|
||||
const selections: Selections = {
|
||||
...selectionRanges,
|
||||
codeBasedSelections: isShiftDown
|
||||
? [...selectionRanges.codeBasedSelections, { range: sourceRange, type }]
|
||||
: [{ range: sourceRange, type }],
|
||||
}
|
||||
setCursor(selections)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user