mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-29 09:49:04 +00:00
core, ui: support trailing punctuation for mentions, URIs (also support domains), and email addresses (#5888)
* core: improve markdown parser for mentions, URIs, and email addresses * ui
This commit is contained in:
+1
-1
@@ -3902,7 +3902,7 @@ enum class MsgContentTag {
|
||||
class FormattedText(val text: String, val format: Format? = null) {
|
||||
// TODO make it dependent on simplexLinkMode preference
|
||||
fun link(mode: SimplexLinkMode): String? = when (format) {
|
||||
is Format.Uri -> text
|
||||
is Format.Uri -> if (text.startsWith("http://", ignoreCase = true) || text.startsWith("https://", ignoreCase = true)) text else "https://$text"
|
||||
is Format.SimplexLink -> if (mode == SimplexLinkMode.BROWSER) text else format.simplexUri
|
||||
is Format.Email -> "mailto:$text"
|
||||
is Format.Phone -> "tel:$text"
|
||||
|
||||
+9
-1
@@ -23,6 +23,12 @@ import chat.simplex.common.views.chatlist.setGroupMembers
|
||||
import chat.simplex.common.views.helpers.*
|
||||
import chat.simplex.res.MR
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.text.CharCategory.*
|
||||
|
||||
val punctuation = setOf(
|
||||
DASH_PUNCTUATION, START_PUNCTUATION, END_PUNCTUATION,
|
||||
CONNECTOR_PUNCTUATION, OTHER_PUNCTUATION
|
||||
)
|
||||
|
||||
private val PICKER_ROW_SIZE = MEMBER_ROW_AVATAR_SIZE + (MEMBER_ROW_VERTICAL_PADDING * 2f)
|
||||
private val MAX_PICKER_HEIGHT = (PICKER_ROW_SIZE * 4) + (MEMBER_ROW_AVATAR_SIZE + MEMBER_ROW_VERTICAL_PADDING - 4.dp)
|
||||
@@ -126,7 +132,9 @@ fun GroupMentions(
|
||||
}
|
||||
val newName = existingMention?.key ?: composeState.value.mentionMemberName(member.memberProfile.displayName)
|
||||
mentions[newName] = CIMention(member)
|
||||
var msgMention = "@" + if (newName.contains(" ")) "'$newName'" else newName
|
||||
var msgMention = if (newName.contains(" ") || (newName.lastOrNull()?.category in punctuation))
|
||||
"@'$newName'"
|
||||
else "@$newName"
|
||||
var newPos = range.start + msgMention.length
|
||||
val newMsgLength = composeState.value.message.text.length + msgMention.length - range.length
|
||||
if (newPos == newMsgLength) {
|
||||
|
||||
Reference in New Issue
Block a user