impr: use modals for replies, close #466

This commit is contained in:
James Xylight committed 2025-06-10 11:59:00 -07:00
1 parent 8232903bbe
commit 7e2590585d
7 files changed
+112 -140

No files matched your search

@@ -57,11 +57,11 @@
let image = $state<FileList | null | undefined>(null)
const shortcuts = {
KeyB: () => wrapSelection('**', '**'),
KeyI: () => wrapSelection('*', '*'),
KeyS: () => wrapSelection('~~', '~~'),
KeyH: () => wrapSelection('\n# ', ''),
KeyK: () => wrapSelection('[](', ')'),
b: () => wrapSelection('**', '**'),
i: () => wrapSelection('*', '*'),
s: () => wrapSelection('~~', '~~'),
h: () => wrapSelection('\n# ', ''),
k: () => wrapSelection('[](', ')'),
}
async function adjustHeight() {
@@ -72,6 +72,18 @@
}
}
function handleKeydown(
event: KeyboardEvent & {
currentTarget: EventTarget & HTMLTextAreaElement
},
) {
if (event.ctrlKey && event.key === 'Enter') {
event.preventDefault()
const form = textArea?.closest('form')
if (form) form.requestSubmit() // Automatically submits the form
}
}
interface Props extends TextAreaProps {
images?: boolean
value?: string
@@ -255,8 +267,9 @@ overflow-hidden transition-colors {clazz}"
onkeydown={e => {
if (disabled) return
if (e.ctrlKey || e.metaKey) {
handleKeydown(e)
// @ts-expect-error yes it can
let shortcut = shortcuts[e.code]
let shortcut = shortcuts[e.key]
if (shortcut) {
e.preventDefault()
shortcut?.(e)