mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-15 09:04:45 +00:00
fix(StatusMessageReply): Fixed text formatting in replied message
This commit is contained in:
parent
8f254279e1
commit
09d8a10b49
@ -221,6 +221,9 @@ Rectangle {
|
||||
profileClickable: root.profileClickable
|
||||
onReplyProfileClicked: root.replyProfileClicked(sender, mouse)
|
||||
audioMessageInfoText: root.audioMessageInfoText
|
||||
onLinkActivated: {
|
||||
root.linkActivated(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,25 +289,8 @@ Rectangle {
|
||||
visible: active
|
||||
sourceComponent: StatusTextMessage {
|
||||
objectName: "StatusMessage_textMessage"
|
||||
textField.text: {
|
||||
if (root.messageDetails.contentType === StatusMessage.ContentType.Sticker)
|
||||
return "";
|
||||
|
||||
const formattedMessage = Utils.linkifyAndXSS(root.messageDetails.messageText);
|
||||
|
||||
if (root.messageDetails.contentType === StatusMessage.ContentType.Emoji)
|
||||
return Emoji.parse(formattedMessage, Emoji.size.middle, Emoji.format.png);
|
||||
|
||||
if (root.isEdited) {
|
||||
const index = formattedMessage.endsWith("code>") ? formattedMessage.length : formattedMessage.length - 4;
|
||||
const editedMessage = formattedMessage.slice(0, index)
|
||||
+ ` <span class="isEdited">` + qsTr("(edited)") + `</span>`
|
||||
+ formattedMessage.slice(index);
|
||||
return Utils.getMessageWithStyle(Emoji.parse(editedMessage), textField.hoveredLink)
|
||||
}
|
||||
|
||||
return Utils.getMessageWithStyle(Emoji.parse(formattedMessage), textField.hoveredLink)
|
||||
}
|
||||
messageDetails: root.messageDetails
|
||||
isEdited: root.isEdited
|
||||
onLinkActivated: {
|
||||
root.linkActivated(link);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ Item {
|
||||
property bool profileClickable: true
|
||||
|
||||
signal replyProfileClicked(var sender, var mouse)
|
||||
signal linkActivated(string link)
|
||||
|
||||
implicitHeight: layout.implicitHeight
|
||||
implicitWidth: layout.implicitWidth
|
||||
@ -83,12 +84,16 @@ Item {
|
||||
}
|
||||
StatusTextMessage {
|
||||
Layout.fillWidth: true
|
||||
textField.text: replyDetails.messageText
|
||||
textField.font.pixelSize: Theme.secondaryTextFontSize
|
||||
textField.color: Theme.palette.baseColor1
|
||||
convertToSingleLine: true
|
||||
clip: true
|
||||
visible: !!replyDetails.messageText && replyDetails.contentType !== StatusMessage.ContentType.Sticker
|
||||
allowShowMore: false
|
||||
messageDetails: root.replyDetails
|
||||
onLinkActivated: {
|
||||
root.linkActivated(link);
|
||||
}
|
||||
}
|
||||
StatusImageMessage {
|
||||
Layout.fillWidth: true
|
||||
|
@ -4,10 +4,15 @@ import QtGraphicalEffects 1.0
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property StatusMessageDetails messageDetails: StatusMessageDetails {}
|
||||
property bool isEdited: false
|
||||
property bool convertToSingleLine: false
|
||||
|
||||
property alias textField: chatText
|
||||
property bool allowShowMore: true
|
||||
|
||||
@ -21,19 +26,46 @@ Item {
|
||||
property bool readMore: false
|
||||
readonly property bool veryLongChatText: chatText.length > 1000
|
||||
readonly property int showMoreHeight: showMoreLoader.visible ? showMoreLoader.height : 0
|
||||
|
||||
readonly property string text: {
|
||||
if (root.messageDetails.contentType === StatusMessage.ContentType.Sticker)
|
||||
return "";
|
||||
|
||||
const formattedMessage = Utils.linkifyAndXSS(root.messageDetails.messageText);
|
||||
|
||||
if (root.messageDetails.contentType === StatusMessage.ContentType.Emoji)
|
||||
return Emoji.parse(formattedMessage, Emoji.size.middle, Emoji.format.png);
|
||||
|
||||
if (root.isEdited) {
|
||||
const index = formattedMessage.endsWith("code>") ? formattedMessage.length : formattedMessage.length - 4;
|
||||
const editedMessage = formattedMessage.slice(0, index)
|
||||
+ ` <span class="isEdited">` + qsTr("(edited)") + `</span>`
|
||||
+ formattedMessage.slice(index);
|
||||
return Utils.getMessageWithStyle(Emoji.parse(editedMessage), chatText.hoveredLink)
|
||||
}
|
||||
|
||||
if (root.convertToSingleLine) {
|
||||
const singleLineMessage = Utils.convertToSingleLine(formattedMessage)
|
||||
return Utils.getMessageWithStyle(Emoji.parse(singleLineMessage), chatText.hoveredLink)
|
||||
}
|
||||
|
||||
return Utils.getMessageWithStyle(Emoji.parse(formattedMessage), chatText.hoveredLink)
|
||||
}
|
||||
}
|
||||
|
||||
TextEdit {
|
||||
id: chatText
|
||||
objectName: "StatusTextMessage_chatText"
|
||||
|
||||
readonly property int effectiveHeight: d.veryLongChatText && !d.readMore ? Math.min(chatText.implicitHeight, 200)
|
||||
: chatText.implicitHeight
|
||||
readonly property int effectiveHeight: d.veryLongChatText && !d.readMore
|
||||
? Math.min(chatText.implicitHeight, 200)
|
||||
: chatText.implicitHeight
|
||||
|
||||
width: parent.width
|
||||
height: effectiveHeight + d.showMoreHeight / 2
|
||||
visible: !opMask.active
|
||||
clip: true
|
||||
text: d.text
|
||||
selectedTextColor: Theme.palette.directColor1
|
||||
selectionColor: Theme.palette.primaryColor3
|
||||
color: Theme.palette.directColor1
|
||||
|
@ -218,6 +218,10 @@ QtObject {
|
||||
`${msg}`
|
||||
}
|
||||
|
||||
function convertToSingleLine(text) {
|
||||
return text.replace(/<br\s*\/>/gm, " ")
|
||||
}
|
||||
|
||||
function delegateModelSort(srcGroup, dstGroup, lessThan) {
|
||||
const insertPosition = (lessThan, item) => {
|
||||
let lower = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user