fix: ctrl + enter in forms, close #362
This commit is contained in:
1 parent
b7e503ae4f
commit
5ea1f2e0cf
2 files changed
+11
-3
No files matched your search
@@ -17,7 +17,10 @@
|
|||||||
export let rows: number = 7
|
export let rows: number = 7
|
||||||
export let placeholder: string | undefined = undefined
|
export let placeholder: string | undefined = undefined
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{ comment: CommentResponse }>()
|
const dispatch = createEventDispatcher<{
|
||||||
|
comment: CommentResponse
|
||||||
|
confirm: string
|
||||||
|
}>()
|
||||||
|
|
||||||
export let value = ''
|
export let value = ''
|
||||||
export let actions = true
|
export let actions = true
|
||||||
@@ -76,6 +79,7 @@
|
|||||||
on:confirm={() => {
|
on:confirm={() => {
|
||||||
if (actions) {
|
if (actions) {
|
||||||
submit()
|
submit()
|
||||||
|
dispatch('confirm', value)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:focus
|
on:focus
|
||||||
|
|||||||
@@ -105,7 +105,11 @@
|
|||||||
KeyS: () => wrapSelection('~~', '~~'),
|
KeyS: () => wrapSelection('~~', '~~'),
|
||||||
KeyH: () => wrapSelection('\n# ', ''),
|
KeyH: () => wrapSelection('\n# ', ''),
|
||||||
KeyK: () => wrapSelection('[](', ')'),
|
KeyK: () => wrapSelection('[](', ')'),
|
||||||
Enter: () => dispatcher('confirm', value),
|
Enter: (e: any) => {
|
||||||
|
dispatcher('confirm', value)
|
||||||
|
const newEvent = new Event('submit', { cancelable: true })
|
||||||
|
e.target.form.dispatchEvent(newEvent)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -295,7 +299,7 @@ overflow-hidden transition-colors"
|
|||||||
let shortcut = shortcuts[e.code]
|
let shortcut = shortcuts[e.code]
|
||||||
if (shortcut) {
|
if (shortcut) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shortcut?.()
|
shortcut?.(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in new issue
Block a user