feat: add and close #94

This commit is contained in:
Xyphyn committed 2023-08-11 13:59:24 -07:00
1 parent b1356ffb66
commit a5c41a9c90
2 files changed
+8 -1

No files matched your search

@@ -73,7 +73,8 @@
? 'This post is locked.'
: placeholders.get('comment')}
bind:value
disabled={locked}
disabled={locked || loading}
on:confirm={submit}
/>
{/if}
{#if actions || previewAction}
@@ -8,6 +8,7 @@
import Modal from '$lib/components/ui/modal/Modal.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { uploadImage } from '$lib/lemmy.js'
import { createEventDispatcher } from 'svelte'
import {
CodeBracket,
ExclamationTriangle,
@@ -21,6 +22,9 @@
export let value: string = ''
export let label: string | undefined = undefined
export let previewButton: boolean = false
export let disabled: boolean = false
const dispatcher = createEventDispatcher<{ confirm: string }>()
let textArea: HTMLTextAreaElement
@@ -89,6 +93,7 @@
KeyS: () => wrapSelection('~~', '~~'),
KeyH: () => wrapSelection('\n# ', ''),
KeyK: () => wrapSelection('[](', ')'),
Enter: () => dispatcher('confirm', value),
}
</script>
@@ -223,6 +228,7 @@ overflow-hidden focus-within:border-black focus-within:dark:border-white transit
bind:value
bind:item={textArea}
on:keydown={(e) => {
if (disabled) return
if (e.ctrlKey) {
// @ts-ignore
let shortcut = shortcuts[e.code]