chore: fix emoji token rendering in HTML messages (#2913)

This commit is contained in:
ggurdin 2025-06-03 13:52:15 -04:00 committed by GitHub
parent 7cb254ceef
commit c8fdcda3fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View file

@ -1486,6 +1486,16 @@ class ChatController extends State<ChatPageWithRoom>
void typeEmoji(Emoji? emoji) {
if (emoji == null) return;
final text = sendController.text;
// #Pangea
if (!sendController.selection.isValid) {
sendController.value = TextEditingValue(
text: text,
selection: TextSelection.collapsed(offset: text.length),
);
}
// Pangea#
final selection = sendController.selection;
final newText = sendController.text.isEmpty
? emoji.emoji

View file

@ -193,8 +193,13 @@ class HtmlMessage extends StatelessWidget {
if (tokenIndex == -1) continue;
final int tokenLength = tokenText.characters.length;
final before = result[substringIndex].substring(0, tokenIndex);
final after = result[substringIndex].substring(tokenIndex + tokenLength);
final before =
result[substringIndex].characters.take(tokenIndex).toString();
final after = result[substringIndex]
.characters
.skip(tokenIndex + tokenLength)
.toString();
result.replaceRange(substringIndex, substringIndex + 1, [
if (before.isNotEmpty) before,
'<token offset="${token.text.offset}" length="${token.text.length}">$tokenText</token>',