Set up default messaging relays

This commit is contained in:
Jon Staab
2026-03-23 14:21:04 -07:00
parent b716f3f792
commit 1de6d7a874
11 changed files with 173 additions and 114 deletions
+14 -6
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import {onDestroy, onMount} from "svelte"
import {writable} from "svelte/store"
import cx from "classnames"
import type {EventContent} from "@welshman/util"
import {isMobile, preventDefault} from "@lib/html"
import GallerySend from "@assets/icons/gallery-send.svg?dataurl"
@@ -12,17 +13,24 @@
type Props = {
content?: string
disabled?: boolean
onEscape?: () => void
onEditPrevious?: () => void
onSubmit: (event: EventContent) => void
}
const {content, onEscape, onEditPrevious, onSubmit}: Props = $props()
const {content, disabled = false, onEscape, onEditPrevious, onSubmit}: Props = $props()
const autofocus = !isMobile
const autofocus = !isMobile && !disabled
const uploading = writable(false)
const editorClass = $derived(
cx("chat-editor flex-grow overflow-hidden", {
"pointer-events-none opacity-50": disabled,
}),
)
export const focus = () => editor.then(ed => ed.chain().focus().run())
export const canEnterEditPrevious = () =>
@@ -41,7 +49,7 @@
const uploadFiles = () => editor.then(ed => ed.chain().selectFiles().run())
const submit = async () => {
if ($uploading) return
if ($uploading || disabled) return
const ed = await editor
const content = ed.getText({blockSeparator: "\n"}).trim()
@@ -78,7 +86,7 @@
<Button
data-tip="Add an image"
class="center tooltip tooltip-right h-10 w-10 min-w-10 rounded-box bg-base-300 transition-colors hover:bg-base-200"
disabled={$uploading}
disabled={$uploading || disabled}
onclick={uploadFiles}>
{#if $uploading}
<span class="loading loading-spinner loading-xs"></span>
@@ -86,13 +94,13 @@
<Icon icon={GallerySend} />
{/if}
</Button>
<div class="chat-editor flex-grow overflow-hidden">
<div class={editorClass} aria-disabled={disabled}>
<EditorContent {editor} />
</div>
<Button
data-tip="{window.navigator.platform.includes('Mac') ? 'cmd' : 'ctrl'}+enter to send"
class="center tooltip tooltip-left absolute right-4 h-10 w-10 min-w-10 rounded-full"
disabled={$uploading}
disabled={$uploading || disabled}
onclick={submit}>
<Icon icon={Plane} />
</Button>