Skip to content

Commit

Permalink
Merge pull request #8711 from element-hq/dependabot/gradle/io.element…
Browse files Browse the repository at this point in the history
….android-wysiwyg-2.22.0

Bump io.element.android:wysiwyg from 2.14.1 to 2.22.0
  • Loading branch information
bmarty authored Dec 20, 2023
2 parents 431a1a6 + 644587a commit 6feee61
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ext.libs = [
],
element : [
'opusencoder' : "io.element.android:opusencoder:1.1.0",
'wysiwyg' : "io.element.android:wysiwyg:2.14.1"
'wysiwyg' : "io.element.android:wysiwyg:2.22.0"
],
squareup : [
'moshi' : "com.squareup.moshi:moshi:$moshi",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class AutoCompleter @AssistedInject constructor(
private fun insertMatrixItemIntoRichTextEditor(editorEditText: EditorEditText, matrixItem: MatrixItem) {
if (matrixItem is MatrixItem.EveryoneInRoomItem) {
editorEditText.replaceTextSuggestion(matrixItem.displayName)
// Note: not using editorEditText.insertAtRoomMentionAtSuggestion() since we want to keep the existing look and feel of the mention for @room.
return
}

Expand All @@ -253,7 +254,7 @@ class AutoCompleter @AssistedInject constructor(
matrixItem.getBestName()
}

editorEditText.setLinkSuggestion(url = permalink, text = linkText)
editorEditText.insertMentionAtSuggestion(url = permalink, text = linkText)
}

private fun insertMatrixItemIntoEditable(editText: EditText, editable: Editable, firstChar: Char, matrixItem: MatrixItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
override val attachmentButton: ImageButton
get() = views.attachmentButton

val richTextEditText: EditText get() =
views.richTextComposerEditText
val plainTextEditText: EditText get() =
views.plainTextComposerEditText
val richTextEditText: EditText
get() = views.richTextComposerEditText
val plainTextEditText: EditText
get() = views.plainTextComposerEditText

var pillDisplayHandler: PillDisplayHandler? = null

Expand Down Expand Up @@ -237,14 +237,16 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
views.composerEditTextOuterBorder.background = borderShapeDrawable

setupRichTextMenu()
views.richTextComposerEditText.mentionDisplayHandler = object : MentionDisplayHandler {
override fun resolveMentionDisplay(text: String, url: String): TextDisplay =
pillDisplayHandler?.resolveMentionDisplay(text, url) ?: TextDisplay.Plain

override fun resolveAtRoomMentionDisplay(): TextDisplay =
pillDisplayHandler?.resolveAtRoomMentionDisplay() ?: TextDisplay.Plain
}

views.richTextComposerEditText.updateStyle(
styleConfig = views.richTextComposerEditText.styleConfig,
mentionDisplayHandler = object : MentionDisplayHandler {
override fun resolveMentionDisplay(text: String, url: String): TextDisplay =
pillDisplayHandler?.resolveMentionDisplay(text, url) ?: TextDisplay.Plain

override fun resolveAtRoomMentionDisplay(): TextDisplay =
pillDisplayHandler?.resolveAtRoomMentionDisplay() ?: TextDisplay.Plain
}
)
updateTextFieldBorder(isFullScreen)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlUiState
import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlView
import im.vector.app.features.media.ImageContentRenderer
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
import io.element.android.wysiwyg.EditorStyledTextView
import io.noties.markwon.MarkwonPlugin
import org.matrix.android.sdk.api.extensions.orFalse

Expand Down Expand Up @@ -138,13 +139,19 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
val previewUrlView by bind<PreviewUrlView>(R.id.messageUrlPreview)
private val richMessageStub by bind<ViewStub>(R.id.richMessageTextViewStub)
private val plainMessageStub by bind<ViewStub>(R.id.plainMessageTextViewStub)
var richMessageView: AppCompatTextView? = null
var richMessageView: EditorStyledTextView? = null
private set
var plainMessageView: AppCompatTextView? = null
private set

fun requireRichMessageView(): AppCompatTextView {
val view = richMessageView ?: richMessageStub.inflate().findViewById(R.id.messageTextView)
val view = richMessageView ?: richMessageStub.inflate().findViewById<EditorStyledTextView>(R.id.messageTextView).also {
// Required to ensure that `inlineCodeBgHelper` and `codeBlockBgHelper` are initialized
it.updateStyle(
styleConfig = it.styleConfig,
mentionDisplayHandler = null,
)
}
richMessageView = view
return view
}
Expand Down

0 comments on commit 6feee61

Please sign in to comment.