fix: word wrap + breaklines

This commit is contained in:
Richard Ramos 2020-06-25 16:17:42 -04:00 committed by Iuri Matias
parent 92b75ead74
commit 8e21a1b8b3
3 changed files with 4 additions and 3 deletions

View File

@ -34,6 +34,7 @@ proc renderBlock(self: ChatMessageList, message: Message): string =
of "blockquote": of "blockquote":
# TODO: extract this from the theme somehow # TODO: extract this from the theme somehow
var color = if message.isCurrentUser: "#FFFFFF" else: "#666666" var color = if message.isCurrentUser: "#FFFFFF" else: "#666666"
result = result & fmt("<span style=\"color: {color}\">▍ ") & pMsg.literal[1 .. ^1] & "</span>" result = result & fmt("<span style=\"color: {color}\">▍ ") & pMsg.literal & "</span>"
of "codeblock": of "codeblock":
result = "<table style=\"background-color: #1a356b;\"><tr><td style=\"padding: 5px;\"><code style=\"color: #ffffff\">" & pMsg.literal & "</code></td></tr></table>" result = "<table style=\"background-color: #1a356b;\"><tr><td style=\"padding: 5px;\"><code style=\"color: #ffffff\">" & pMsg.literal & "</code></td></tr></table>"
result = result.replace("\n", "<br />")

View File

@ -5,7 +5,7 @@ import ../../../status/chat
import ../../../status/chat/[message,stickers] import ../../../status/chat/[message,stickers]
import ../../../status/profile/profile import ../../../status/profile/profile
import ../../../status/ens import ../../../status/ens
import strformat import strformat, strutils
type type
ChatMessageRoles {.pure.} = enum ChatMessageRoles {.pure.} = enum

View File

@ -242,7 +242,7 @@ Item {
anchors.right: message.length > 52 ? parent.right : undefined anchors.right: message.length > 52 ? parent.right : undefined
anchors.rightMargin: message.length > 52 ? parent.chatHorizontalPadding : 0 anchors.rightMargin: message.length > 52 ? parent.chatHorizontalPadding : 0
horizontalAlignment: !isCurrentUser ? Text.AlignLeft : Text.AlignRight horizontalAlignment: !isCurrentUser ? Text.AlignLeft : Text.AlignRight
wrapMode: Text.WrapAnywhere wrapMode: Text.Wrap
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: chatBox.chatVerticalPadding anchors.topMargin: chatBox.chatVerticalPadding
font.pixelSize: 15 font.pixelSize: 15