Bump wysiwyg from 0.4.0 to 0.7.0 (#7572)
* Bump wysiwyg from 0.4.0 to 0.6.0 Bumps [wysiwyg](https://github.com/matrix-org/matrix-wysiwyg) from 0.4.0 to 0.6.0. - [Release notes](https://github.com/matrix-org/matrix-wysiwyg/releases) - [Changelog](https://github.com/matrix-org/matrix-rich-text-editor/blob/main/RELEASE.md) - [Commits](https://github.com/matrix-org/matrix-wysiwyg/compare/0.4.0...0.6.0) --- updated-dependencies: - dependency-name: io.element.android:wysiwyg dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update RTE library to 0.7.0 * Fix markdown -> html Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín <jorgem@element.io>
This commit is contained in:
parent
6be22a5e7f
commit
1fe790e46f
|
@ -98,7 +98,7 @@ ext.libs = [
|
||||||
],
|
],
|
||||||
element : [
|
element : [
|
||||||
'opusencoder' : "io.element.android:opusencoder:1.1.0",
|
'opusencoder' : "io.element.android:opusencoder:1.1.0",
|
||||||
'wysiwyg' : "io.element.android:wysiwyg:0.4.0"
|
'wysiwyg' : "io.element.android:wysiwyg:0.7.0"
|
||||||
],
|
],
|
||||||
squareup : [
|
squareup : [
|
||||||
'moshi' : "com.squareup.moshi:moshi:$moshi",
|
'moshi' : "com.squareup.moshi:moshi:$moshi",
|
||||||
|
|
|
@ -48,8 +48,8 @@ import im.vector.app.databinding.ComposerRichTextLayoutBinding
|
||||||
import im.vector.app.databinding.ViewRichTextMenuButtonBinding
|
import im.vector.app.databinding.ViewRichTextMenuButtonBinding
|
||||||
import io.element.android.wysiwyg.EditorEditText
|
import io.element.android.wysiwyg.EditorEditText
|
||||||
import io.element.android.wysiwyg.inputhandlers.models.InlineFormat
|
import io.element.android.wysiwyg.inputhandlers.models.InlineFormat
|
||||||
|
import uniffi.wysiwyg_composer.ActionState
|
||||||
import uniffi.wysiwyg_composer.ComposerAction
|
import uniffi.wysiwyg_composer.ComposerAction
|
||||||
import uniffi.wysiwyg_composer.MenuState
|
|
||||||
|
|
||||||
class RichTextComposerLayout @JvmOverloads constructor(
|
class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -206,16 +206,16 @@ class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupRichTextMenu() {
|
private fun setupRichTextMenu() {
|
||||||
addRichTextMenuItem(R.drawable.ic_composer_bold, R.string.rich_text_editor_format_bold, ComposerAction.Bold) {
|
addRichTextMenuItem(R.drawable.ic_composer_bold, R.string.rich_text_editor_format_bold, ComposerAction.BOLD) {
|
||||||
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.Bold)
|
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.Bold)
|
||||||
}
|
}
|
||||||
addRichTextMenuItem(R.drawable.ic_composer_italic, R.string.rich_text_editor_format_italic, ComposerAction.Italic) {
|
addRichTextMenuItem(R.drawable.ic_composer_italic, R.string.rich_text_editor_format_italic, ComposerAction.ITALIC) {
|
||||||
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.Italic)
|
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.Italic)
|
||||||
}
|
}
|
||||||
addRichTextMenuItem(R.drawable.ic_composer_underlined, R.string.rich_text_editor_format_underline, ComposerAction.Underline) {
|
addRichTextMenuItem(R.drawable.ic_composer_underlined, R.string.rich_text_editor_format_underline, ComposerAction.UNDERLINE) {
|
||||||
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.Underline)
|
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.Underline)
|
||||||
}
|
}
|
||||||
addRichTextMenuItem(R.drawable.ic_composer_strikethrough, R.string.rich_text_editor_format_strikethrough, ComposerAction.StrikeThrough) {
|
addRichTextMenuItem(R.drawable.ic_composer_strikethrough, R.string.rich_text_editor_format_strikethrough, ComposerAction.STRIKE_THROUGH) {
|
||||||
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.StrikeThrough)
|
views.richTextComposerEditText.toggleInlineFormat(InlineFormat.StrikeThrough)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,12 +238,9 @@ class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
override fun onAttachedToWindow() {
|
override fun onAttachedToWindow() {
|
||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
|
|
||||||
views.richTextComposerEditText.menuStateChangedListener = EditorEditText.OnMenuStateChangedListener { state ->
|
views.richTextComposerEditText.actionStatesChangedListener = EditorEditText.OnActionStatesChangedListener { state ->
|
||||||
if (state is MenuState.Update) {
|
for (action in state.keys) {
|
||||||
updateMenuStateFor(ComposerAction.Bold, state)
|
updateMenuStateFor(action, state)
|
||||||
updateMenuStateFor(ComposerAction.Italic, state)
|
|
||||||
updateMenuStateFor(ComposerAction.Underline, state)
|
|
||||||
updateMenuStateFor(ComposerAction.StrikeThrough, state)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,9 +258,9 @@ class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
*/
|
*/
|
||||||
private fun syncEditTexts() =
|
private fun syncEditTexts() =
|
||||||
if (isTextFormattingEnabled) {
|
if (isTextFormattingEnabled) {
|
||||||
views.plainTextComposerEditText.setText(views.richTextComposerEditText.getPlainText())
|
views.plainTextComposerEditText.setText(views.richTextComposerEditText.getMarkdown())
|
||||||
} else {
|
} else {
|
||||||
views.richTextComposerEditText.setText(views.plainTextComposerEditText.text.toString())
|
views.richTextComposerEditText.setMarkdown(views.plainTextComposerEditText.text.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addRichTextMenuItem(@DrawableRes iconId: Int, @StringRes description: Int, action: ComposerAction, onClick: () -> Unit) {
|
private fun addRichTextMenuItem(@DrawableRes iconId: Int, @StringRes description: Int, action: ComposerAction, onClick: () -> Unit) {
|
||||||
|
@ -279,10 +276,11 @@ class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMenuStateFor(action: ComposerAction, menuState: MenuState.Update) {
|
private fun updateMenuStateFor(action: ComposerAction, menuState: Map<ComposerAction, ActionState>) {
|
||||||
val button = findViewWithTag<ImageButton>(action) ?: return
|
val button = findViewWithTag<ImageButton>(action) ?: return
|
||||||
button.isEnabled = !menuState.disabledActions.contains(action)
|
val stateForAction = menuState[action]
|
||||||
button.isSelected = menuState.reversedActions.contains(action)
|
button.isEnabled = stateForAction != ActionState.DISABLED
|
||||||
|
button.isSelected = stateForAction == ActionState.REVERSED
|
||||||
}
|
}
|
||||||
|
|
||||||
fun estimateCollapsedHeight(): Int {
|
fun estimateCollapsedHeight(): Int {
|
||||||
|
|
Loading…
Reference in New Issue