v0.9.14 adjusted emoticon and image view.

This commit is contained in:
2026-03-14 13:52:58 -04:00
parent 2d0214fc10
commit 2ffa6202f1
7 changed files with 50 additions and 20 deletions

View File

@@ -166,10 +166,33 @@ export default function MessageInput({ group, replyTo, onCancelReply, onSend, on
await onSend({ content: trimmed || null, imageFile, linkPreview: lp, emojiOnly });
};
// Send a single emoji directly (from picker)
const handleEmojiSend = async (emoji) => {
// Insert emoji at cursor position in the textarea
const handleEmojiSelect = (emoji) => {
setShowEmojiPicker(false);
await onSend({ content: emoji.native, imageFile: null, linkPreview: null, emojiOnly: true });
const el = inputRef.current;
const native = emoji.native;
if (el) {
const start = el.selectionStart ?? 0;
const end = el.selectionEnd ?? 0;
const newText = text.slice(0, start) + native + text.slice(end);
setText(newText);
// Restore focus and move cursor after the inserted emoji
requestAnimationFrame(() => {
el.focus();
const pos = start + native.length;
el.setSelectionRange(pos, pos);
// Resize textarea
el.style.height = 'auto';
const lineHeight = parseFloat(getComputedStyle(el).lineHeight);
const maxHeight = lineHeight * 5 + 20;
el.style.height = Math.min(el.scrollHeight, maxHeight) + 'px';
el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';
});
} else {
// No ref yet — just append
setText(prev => prev + native);
}
};
const compressImage = (file) => new Promise((resolve) => {
@@ -326,7 +349,7 @@ export default function MessageInput({ group, replyTo, onCancelReply, onSend, on
<div className="emoji-input-picker" ref={emojiPickerRef}>
<Picker
data={data}
onEmojiSelect={handleEmojiSend}
onEmojiSelect={handleEmojiSelect}
theme="light"
previewPosition="none"
skinTonePosition="none"