mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +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:
@ -312,6 +312,13 @@ const EncryptedSocketChat: React.FC<Props> = ({
|
|||||||
label={t('Type a message')}
|
label={t('Type a message')}
|
||||||
variant='standard'
|
variant='standard'
|
||||||
size='small'
|
size='small'
|
||||||
|
multiline
|
||||||
|
maxRows={3}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
|
onButtonClicked(e);
|
||||||
|
}
|
||||||
|
}}
|
||||||
helperText={
|
helperText={
|
||||||
connected
|
connected
|
||||||
? peerPubKey
|
? peerPubKey
|
||||||
|
|||||||
@ -299,6 +299,13 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
|||||||
label={t('Type a message')}
|
label={t('Type a message')}
|
||||||
variant='standard'
|
variant='standard'
|
||||||
size='small'
|
size='small'
|
||||||
|
multiline
|
||||||
|
maxRows={3}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
|
onButtonClicked(e);
|
||||||
|
}
|
||||||
|
}}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setValue(e.target.value);
|
setValue(e.target.value);
|
||||||
|
|||||||
@ -126,7 +126,14 @@ const MessageCard: React.FC<Props> = ({ message, isTaker, userConnected, baseUrl
|
|||||||
{message.encryptedMessage}{' '}
|
{message.encryptedMessage}{' '}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
message.plainTextMessage
|
<>
|
||||||
|
{message.plainTextMessage.split('\n').map((messageLine, idx) => (
|
||||||
|
<span key={idx}>
|
||||||
|
{messageLine}
|
||||||
|
<br />
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
subheaderTypographyProps={{
|
subheaderTypographyProps={{
|
||||||
|
|||||||
Reference in New Issue
Block a user