chore: fix emoji token rendering in HTML messages (#2913)
This commit is contained in:
parent
7cb254ceef
commit
c8fdcda3fb
2 changed files with 17 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue