mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Add support for multiline chat (#595)
* Support newlines for sender - add multiline prop - default behavior is not to submit the form when enter is hit, so listen for keypresses and trigger a synthetic button click when enter is hit - however shift+enter is reserved for newlines, so we also check for those * Support newlines for receiver If decrypted message containes newlines, split and render on multiple lines * Also add newline support for turtle mode senders * Styling adjustment for send button * Implement styling feedback --------- Co-authored-by: +shyfire131 <shyfire131@shyfire131.net>
This commit is contained in:
parent
b1d5b02009
commit
c9b70dc10d
@ -312,6 +312,13 @@ const EncryptedSocketChat: React.FC<Props> = ({
|
||||
label={t('Type a message')}
|
||||
variant='standard'
|
||||
size='small'
|
||||
multiline
|
||||
maxRows={3}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
onButtonClicked(e);
|
||||
}
|
||||
}}
|
||||
helperText={
|
||||
connected
|
||||
? peerPubKey
|
||||
|
@ -299,6 +299,13 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
label={t('Type a message')}
|
||||
variant='standard'
|
||||
size='small'
|
||||
multiline
|
||||
maxRows={3}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
onButtonClicked(e);
|
||||
}
|
||||
}}
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
setValue(e.target.value);
|
||||
|
@ -126,7 +126,14 @@ const MessageCard: React.FC<Props> = ({ message, isTaker, userConnected, baseUrl
|
||||
{message.encryptedMessage}{' '}
|
||||
</a>
|
||||
) : (
|
||||
message.plainTextMessage
|
||||
<>
|
||||
{message.plainTextMessage.split('\n').map((messageLine, idx) => (
|
||||
<span key={idx}>
|
||||
{messageLine}
|
||||
<br />
|
||||
</span>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
subheaderTypographyProps={{
|
||||
|
Loading…
Reference in New Issue
Block a user