-
Notifications
You must be signed in to change notification settings - Fork 160
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
Plain text editor implementation based on markdown input #2840
Conversation
5e7592d
to
285ecf0
Compare
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
5445910
to
dc32b1b
Compare
57f0c8a
to
7c45bb7
Compare
71cad2a
to
c8e87c1
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.
Thanks, 2 small remarks after a static review, I will test it this morning.
} | ||
} | ||
is TextEditorState.Markdown -> { | ||
val placeholder = if (composerMode.inThread) { |
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 extract the placeholder
computation to limit code duplication?
import io.element.android.libraries.core.extensions.orEmpty | ||
|
||
@Stable | ||
class ImmutableCharSequence(initialText: CharSequence = "") { |
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.
The name is a bit confusing me, since the CharSequence is actually mutable. Maybe rename to StableCharSequence
?
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.
Doing some test. The Markdown composer is working as expected, but when in Rich
, the composer is not emptied when the message is sent, so user can sent the same message several times.
Probably related, but if instead of sending again I close the rich text mode, the application crashes
java.lang.IndexOutOfBoundsException: setSpan (1 ... 1) ends beyond length 0
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, working as expected now!
Nice! I'll release a RTE version compatible with these changes and merge the PR. |
Quality Gate passedIssues Measures |
The Maestro job got stuck after finishing so it was in a limbo. I just force merged. |
Type of change
Content
MarkdownTextInput
, aTextInput
counterpart that uses a simpleEditText
under the hood, instead of the RTE library. This will be the default editor unless the user explicitly enables rich text formatting.MarkdownTextEditorState
to act as a way to interact with theEditText
from Compose code.RichTextEditorState
andMarkdownTextEditorState
into aTextEditorState
sealed interface with some helper functions.MessageComposerPresenter
from the View, as well as adding mention spans to the plain text editor. Sadly, this means having to add aMentionSpanProvider
to presenter, which makes it more difficult to test. I also had to addisTesting
andshowFormatting
properties to the presenter so it can be easily tested. I'll probably iterate on this later.MessageComposerConfig
in theappconfig
module.Known issues:
Needs matrix-org/matrix-rich-text-editor#978.
Motivation and context
The RTE library has been problematic for some users, most of which didn't want to use rich text at all, so enabling
Screenshots / GIFs
I made the 2 editors look exactly the same, even replaced the editor used in some previews and the golden screenshots didn't change.
Tests
Thoroughly test the plain text editor and enabling / disabling text formatting, editing messages, replying to messages, etc.
Tested devices
Checklist