From 29d8845792df5c53c7b099ae3f7d9c26baeecea2 Mon Sep 17 00:00:00 2001 From: jonnyandrew Date: Wed, 17 May 2023 11:59:20 +0100 Subject: [PATCH] Add slash commands to rich text editor --- .../features/home/room/detail/AutoCompleter.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt index 2a5113ef6c..3c6228caeb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt @@ -107,9 +107,6 @@ class AutoCompleter @AssistedInject constructor( } private fun setupCommands(backgroundDrawable: Drawable, editText: EditText) { - // Rich text editor is not yet supported - if (editText is EditorEditText) return - Autocomplete.on(editText) .with(commandAutocompletePolicy) .with(autocompleteCommandPresenter) @@ -117,10 +114,14 @@ class AutoCompleter @AssistedInject constructor( .with(backgroundDrawable) .with(object : AutocompleteCallback { override fun onPopupItemClicked(editable: Editable, item: Command): Boolean { - editable.clear() - editable - .append(item.command) - .append(" ") + if (editText is EditorEditText) { + editText.replaceTextSuggestion(item.command) + } else { + editable.clear() + editable + .append(item.command) + .append(" ") + } return true }