import { h } from 'preact'; import { useRef, useState } from 'preact/hooks'; import { sendMessage } from './api'; import { SHORTCODES } from './emoji/data'; // PR #412: turn :smile: style shortcodes into emoji as the visitor types. const SHORTCODE_RE = /:([a-z0-9_+-]+):/g; const expandShortcodes = (text: string) => text.replace(SHORTCODE_RE, (m, code) => SHORTCODES[code] ?? m); export function Composer({ openPicker }: { openPicker: (cb: (c: string) => void) => void }) { const [text, setText] = useState(''); const input = useRef(null); return (
{ e.preventDefault(); sendMessage(text); setText(''); }}>