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