From a8972c0ec4b3c699a038eb257d1279fbe99a5bc0 Mon Sep 17 00:00:00 2001 From: jonnyandrew Date: Fri, 3 Nov 2023 09:41:53 +0000 Subject: [PATCH] Fix mention detection logic --- .../io/element/android/wysiwyg/utils/HtmlToSpansParser.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platforms/android/library/src/main/java/io/element/android/wysiwyg/utils/HtmlToSpansParser.kt b/platforms/android/library/src/main/java/io/element/android/wysiwyg/utils/HtmlToSpansParser.kt index c77b57518..529d0bdc5 100644 --- a/platforms/android/library/src/main/java/io/element/android/wysiwyg/utils/HtmlToSpansParser.kt +++ b/platforms/android/library/src/main/java/io/element/android/wysiwyg/utils/HtmlToSpansParser.kt @@ -332,13 +332,13 @@ internal class HtmlToSpansParser( val url = last.span.link val innerText = text.subSequence(last.start, text.length).toString() - val isMention = this.isMention?.invoke(innerText, url) == true + val isMention = isMention?.invoke(innerText, url) == true || + last.span.data.containsKey("data-mention-type") - // If the link is not editable or is a mention, tag all but the first character of the anchor text with + // If the link is a mention, tag all but the first character of the anchor text with // ExtraCharacterSpans. These characters will then be taken into account when translating // between editor and composer model indices (see [EditorIndexMapper]). - val isContentEditable = last.span.data.containsKey("contenteditable") && last.span.data["contenteditable"] != "false" - if ((isContentEditable || isMention) && text.length > 1) { + if (isMention && text.length > 1) { addPendingSpan( ExtraCharacterSpan(), last.start + 1, text.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE )