Boustro is a rich text editor for Flutter.
flutter_spanned_controller | |
---|---|
boustro | |
boustro_starter |
Boustro is designed to be extremely customizable.
The boustro library itself does not define any of formatting modifiers or embedded content. Instead, it provides the base infrastructure to implement these components outside of boustro. This way, any custom components can be implemented in user code.
Documentation on writing custom components has not yet been written. For now, check out the
implementation of the start components in boustro_starter
.
Of course, there's some common components a rich text editor is supposed to have out of the box.
To that end, a supplementary library called boustro_starter
is developed alongside boustro.
It contains a bunch of components that you can directly use with boustro.
Boustro defines extensible theming classes that let users customize the base editor, as well as any components implemented outside of boustro itself. These theme classes even support lerping, for a nice animation when switching themes.
Boustro builds on Flutter's built-in text widgets, without any custom rendering, so it runs on all platforms supported by Flutter.
Check out the example.
- Document: Immutable representation of a rich text document.
- Paragraph: Can be either a line of text or (non-inline) embed.
- Line: A line of text with rich formatting.
- Embed: Any content in a document that is not a Line.
- Line modifier: Wraps a line and can change the way it's displayed.
- Text attribute: Applied to text to set its formatting or add gesture recognizers.
- Span: Text range with a text attribute and rules for how the range behaves when text is inserted (whether it is expanded or not).
Boustro is split into 3 packages that are layered on top of each other.
- flutter_spanned_controller: The
TextEditingController
implementation that makes formatting of editable text possible and data structures to represent text formats and formatted text. The structure is similar to Android's Spannable. - boustro: The actual rich text editor.
- boustro_starter: Attributes, line modifiers and embeds to get started with boustro.
- Can't select across lines. I might be able to fix this issue and make line handling (newlines and
backspace at the start to delete lines) less hacky by using only a single
TextField
. However, this would greatly complicate the line paragraph system, and I'm not sure that's worth it. - At most 1 gesture per
TextSpan
.TextSpan
can have a gesture recognizer, but not multiple. We can solve this by using aWidgetSpan
that wraps aGestureRecognizer
, that wraps the actual text span, but that's blocked by: - The same issues prevent me from creating inline embeds (e.g. inline images) using
WidgetSpan
. Please go upvote these issues if you'd like to see these limitations overcome.
- Zefyr: A big inspiration for this project.
Changelogs for the packages document all notable changes.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.