-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate WYSIWYG editor #7288
Integrate WYSIWYG editor #7288
Conversation
754f7f3
to
0cbc8cb
Compare
Please note that this is the just the initial version of the editor, so it lacks some features like autocomplete, lists, links, pills, etc. and might have some corner cases that we might have missed on our testing sessions, that's expected. |
0cbc8cb
to
03ac243
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1 @@ | |||
Add WYSIWYG editor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a 7288.sdk
file to describe the changes in the SDK API? Thanks.
lastMessageContent.formattedBody | ||
} else { | ||
lastMessageContent?.body | ||
} ?: return "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe create an extension
fun MessageContent?.getFormattedBody(): String? {
return if (this is MessageContentWithFormattedBody) {
formattedBody
} else {
this?.body
}
}
newBodyAutoMarkdown: Boolean, | ||
msgType: String, | ||
compatibilityText: String | ||
): Event { | ||
val content = if (newBodyFormattedText != null) { | ||
TextContent(newBodyText.toString(), newBodyFormattedText.toString()).toMessageTextContent(msgType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should consider changing TextContent to have 2 CharSequence members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it probably makes sense to keep using String
for these, as both text
and formattedText
are expected to be the plain text representation of the contents (either a plain text string or the HTML format of that same text). I'm no expert on this part of the code though, so if you think we should change it I can do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. Thanks
@@ -66,7 +67,7 @@ fun EditText.setTextIfDifferent(newText: CharSequence?): Boolean { | |||
// Previous text is the same. No op | |||
return false | |||
} | |||
setText(newText) | |||
setText(newText, TextView.BufferType.SPANNABLE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the extension is used at other places, maybe add a parameter with default value to use TextView.BufferType.SPANNABLE
on demand only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this change wasn't needed, I forgot to revert a test. Great catch!
if (message.isNotEmpty()) { | ||
ParsedCommand.ChangeDisplayNameForRoom(displayName = message) | ||
if (trimmedMessage.isNotEmpty()) { | ||
ParsedCommand.ChangeDisplayNameForRoom(displayName = trimmedMessage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be better to reuse message
name instead of trimmedMessage
to avoid too many changes in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but I had to add a suppression for name shadowing.
autoMarkdown = false | ||
) | ||
} else { | ||
room.sendService().sendFormattedTextMessage(parsedCommand.message.toString(), parsedCommand.formattedMessage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For parity with the if
block, maybe use named param, and 1 per line.
import im.vector.app.databinding.ViewRichTextMenuButtonBinding | ||
import io.element.android.wysiwyg.InlineFormat | ||
|
||
class RichTextComposerView @JvmOverloads constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to RichTextComposerLayout
(see my other remark about renaming)?
defStyleAttr: Int = 0 | ||
) : ConstraintLayout(context, attrs, defStyleAttr), MessageComposer { | ||
|
||
val views: ComposerRichTextLayoutBinding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be private
I think.
override fun onTransitionCancel(transition: Transition) {} | ||
|
||
override fun onTransitionStart(transition: Transition) {} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could extend SimpleTransitionListener
to avoid empty implementation.
android:layout_marginHorizontal="2dp" | ||
android:background="@android:color/transparent" | ||
android:contentDescription="@string/app_name"> | ||
<!-- The contentDescription attr is populated programmatically. This is just to fix lint issues. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to add a tint, so that it works well on light and dark theme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As replied above, the final designs will be implemented on another PR if that's fine.
1609e96
to
820bf8b
Compare
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
@bmarty since @jmartinesp is away, would you be able to merge this? Thanks! |
Type of change
Content
Adds the
io.element.android:wysiwyg
library, which features the new WYSIWYG editor. ModifiedMessageComposerFragment
to be able to toggle between the current composer and the new one using a labs flag.Motivation and context
We want to integrate the initial version of the WYSIWIG editor into the real app to be able to send rich text messages without having to use markdown.
Screenshots / GIFs
Tests
Tested devices
Checklist