Compose has been missing a Rich Text Editor since its inception. I've taken a crack at this previously, as have others.
However, they have all suffered from fundamental limitations in BasicTextField, the foundation of
all text entry in Compose.
This project is an attempt to re-implement text entry from scratch to finally have a solution to the various problems.faw
I've been trying to implement a spell checking text
field in Compose, and keep running up against
the limitations of BasicTextField. Pretty much out of options, I decided to see what it might take
to replace BasicTextField with something that solved all of my needs.
And now, it's working, and at this point, working pretty well.
It's probably not a permanent solution.
BasicTextField2's new state based approach and gap-buffer has reach maturity and includes a lot of what I would need
to replace this, but still cannot handle rich text rendering. So until that is solved, this is the only solution
that I am aware of that ticks every box:
- ✅ 100% Compose Multiplatform
- ✅ Efficient rendering and editing of long-form text
- ✅ Rich text with custom spans
- ✅ Expose scroll state
- ✅ Spell checking
You can Give it a try here.
- Rich text rendering and editable
- Semi-efficient rendering for long form text (only renders what is visible)
- Semi-efficient data structure for text storage & editing. (but not nearly as efficient as the Gap Buffer BTF2 uses under the hood)
- Cursor movement, clicking, keyboard short cuts, ect
- Text selection (highlighting and edit ops)
- copy/cut/paste
- Exposed scroll state, so we can render scroll bars (BTF1 can't do this)
- Doesn't copy and return full contents on each edit, so again better for longer form text. (BTF2 also works this way, but BTF2 doesn't support AnnotatedString for rich content)
- Support custom Rich Span drawing (this allows us to render the traditional Spell Check red squiggle)
- Emits edit events: so if a single character is inserted, you can collect a Flow, and know exactly what change was made. This makes managing Spell Check much more efficient as you can just respell-check the single word that was changed, rather than everything. (BTF2 now finally offers this!)
- Find & Replace UI: Works exactly as you'd expect.
All of the platforms supported by Compose Text Editor are now supported.
- Copy/Paste of rich text always strips the formatting (this is a Compose MP bug)
- Right-to-Left text is probably broken
- Sentence level spell checking is not working as expected
Text Editor:
implementation("com.darkrockstudios:composetexteditor:1.5.0")
Spell Checking addon:
implementation("com.darkrockstudios:composetexteditor-spellcheck:1.5.0")
Find & Replace addon:
implementation("com.darkrockstudios:composetexteditor-find:1.5.0")
