|
|
@ -93,13 +93,16 @@ class MarkdownTextEditorState( |
|
|
|
for (mention in mentions.reversed()) { |
|
|
|
for (mention in mentions.reversed()) { |
|
|
|
val start = charSequence.getSpanStart(mention) |
|
|
|
val start = charSequence.getSpanStart(mention) |
|
|
|
val end = charSequence.getSpanEnd(mention) |
|
|
|
val end = charSequence.getSpanEnd(mention) |
|
|
|
if (mention.type == MentionSpan.Type.USER) { |
|
|
|
when (mention.type) { |
|
|
|
if (mention.rawValue == "@room") { |
|
|
|
MentionSpan.Type.USER -> { |
|
|
|
replace(start, end, "@room") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val link = permalinkBuilder.permalinkForUser(UserId(mention.rawValue)).getOrNull() ?: continue |
|
|
|
val link = permalinkBuilder.permalinkForUser(UserId(mention.rawValue)).getOrNull() ?: continue |
|
|
|
replace(start, end, "[${mention.rawValue}]($link)") |
|
|
|
replace(start, end, "[${mention.rawValue}]($link)") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
MentionSpan.Type.EVERYONE -> { |
|
|
|
|
|
|
|
replace(start, end, "@room") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Nothing to do here yet |
|
|
|
|
|
|
|
MentionSpan.Type.ROOM -> Unit |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -114,14 +117,9 @@ class MarkdownTextEditorState( |
|
|
|
val mentionSpans = text.getSpans<MentionSpan>(0, text.length) |
|
|
|
val mentionSpans = text.getSpans<MentionSpan>(0, text.length) |
|
|
|
return mentionSpans.mapNotNull { mentionSpan -> |
|
|
|
return mentionSpans.mapNotNull { mentionSpan -> |
|
|
|
when (mentionSpan.type) { |
|
|
|
when (mentionSpan.type) { |
|
|
|
MentionSpan.Type.USER -> { |
|
|
|
MentionSpan.Type.USER -> Mention.User(UserId(mentionSpan.rawValue)) |
|
|
|
if (mentionSpan.rawValue == "@room") { |
|
|
|
MentionSpan.Type.EVERYONE -> Mention.AtRoom |
|
|
|
Mention.AtRoom |
|
|
|
MentionSpan.Type.ROOM -> null |
|
|
|
} else { |
|
|
|
|
|
|
|
Mention.User(UserId(mentionSpan.rawValue)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|