Add slash commands to rich text editor
This commit is contained in:
parent
2d1dcd34c0
commit
29d8845792
@ -107,9 +107,6 @@ class AutoCompleter @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCommands(backgroundDrawable: Drawable, editText: EditText) {
|
private fun setupCommands(backgroundDrawable: Drawable, editText: EditText) {
|
||||||
// Rich text editor is not yet supported
|
|
||||||
if (editText is EditorEditText) return
|
|
||||||
|
|
||||||
Autocomplete.on<Command>(editText)
|
Autocomplete.on<Command>(editText)
|
||||||
.with(commandAutocompletePolicy)
|
.with(commandAutocompletePolicy)
|
||||||
.with(autocompleteCommandPresenter)
|
.with(autocompleteCommandPresenter)
|
||||||
@ -117,10 +114,14 @@ class AutoCompleter @AssistedInject constructor(
|
|||||||
.with(backgroundDrawable)
|
.with(backgroundDrawable)
|
||||||
.with(object : AutocompleteCallback<Command> {
|
.with(object : AutocompleteCallback<Command> {
|
||||||
override fun onPopupItemClicked(editable: Editable, item: Command): Boolean {
|
override fun onPopupItemClicked(editable: Editable, item: Command): Boolean {
|
||||||
editable.clear()
|
if (editText is EditorEditText) {
|
||||||
editable
|
editText.replaceTextSuggestion(item.command)
|
||||||
.append(item.command)
|
} else {
|
||||||
.append(" ")
|
editable.clear()
|
||||||
|
editable
|
||||||
|
.append(item.command)
|
||||||
|
.append(" ")
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user