fix(app): line selection ux fixes
This commit is contained in:
@@ -66,28 +66,16 @@ export function Code<T>(props: CodeProps<T>) {
|
||||
"selectedLines",
|
||||
"commentedLines",
|
||||
"onRendered",
|
||||
"onLineSelectionEnd",
|
||||
])
|
||||
|
||||
const [rendered, setRendered] = createSignal(0)
|
||||
|
||||
const handleLineClick: FileOptions<T>["onLineClick"] = (info) => {
|
||||
props.onLineClick?.(info)
|
||||
|
||||
if (props.enableLineSelection !== true) return
|
||||
if (info.numberColumn) return
|
||||
if (!local.selectedLines) return
|
||||
|
||||
file().setSelectedLines(null)
|
||||
}
|
||||
|
||||
const file = createMemo(
|
||||
() =>
|
||||
new File<T>(
|
||||
{
|
||||
...createDefaultOptions<T>("unified"),
|
||||
...others,
|
||||
onLineClick: props.enableLineSelection === true || props.onLineClick ? handleLineClick : undefined,
|
||||
},
|
||||
getWorkerPool("unified"),
|
||||
),
|
||||
@@ -332,12 +320,21 @@ export function Code<T>(props: CodeProps<T>) {
|
||||
if (props.enableLineSelection !== true) return
|
||||
if (dragStart === undefined) return
|
||||
|
||||
if (dragMoved) {
|
||||
pendingSelectionEnd = true
|
||||
scheduleDragUpdate()
|
||||
scheduleSelectionUpdate()
|
||||
if (!dragMoved) {
|
||||
pendingSelectionEnd = false
|
||||
const line = dragStart
|
||||
setSelectedLines({ start: line, end: line })
|
||||
props.onLineSelectionEnd?.(lastSelection)
|
||||
dragStart = undefined
|
||||
dragEnd = undefined
|
||||
dragMoved = false
|
||||
return
|
||||
}
|
||||
|
||||
pendingSelectionEnd = true
|
||||
scheduleDragUpdate()
|
||||
scheduleSelectionUpdate()
|
||||
|
||||
dragStart = undefined
|
||||
dragEnd = undefined
|
||||
dragMoved = false
|
||||
|
||||
Reference in New Issue
Block a user