@@ -79,6 +79,36 @@ Widget defaultSpellCheckMenuBuilder(
7979typedef FleatherEmbedBuilder = Widget Function (
8080 BuildContext context, EmbedNode node);
8181
82+ /// Special configuration for [SpanEmbed] s
83+ class FleatherSpanEmbedConfiguration {
84+ const FleatherSpanEmbedConfiguration (this .embedBuilder,
85+ {this .placeholderAlignment = PlaceholderAlignment .bottom,
86+ this .textBaseline,
87+ this .textStyle});
88+
89+ final FleatherEmbedBuilder embedBuilder;
90+
91+ /// How the placeholder aligns vertically with the text.
92+ ///
93+ /// See [ui.PlaceholderAlignment] for details on each mode.
94+ final PlaceholderAlignment placeholderAlignment;
95+
96+ /// The [TextBaseline] to align against when using [ui.PlaceholderAlignment.baseline] ,
97+ /// [ui.PlaceholderAlignment.aboveBaseline] , and [ui.PlaceholderAlignment.belowBaseline] .
98+ ///
99+ /// This is ignored when using other alignment modes.
100+ final TextBaseline ? textBaseline;
101+
102+ /// The [TextStyle] to apply to this span.
103+ ///
104+ /// The [style] is also applied to any child spans when this is an instance
105+ /// of [TextSpan] .
106+ ///
107+ /// A [TextStyle] may be provided with the [style] property, but only the
108+ /// decoration, foreground, background, and spacing options will be used.
109+ final TextStyle ? textStyle;
110+ }
111+
82112/// Default implementation of a builder function for embeddable objects in
83113/// Fleather.
84114///
@@ -255,6 +285,13 @@ class FleatherEditor extends StatefulWidget {
255285 /// Defaults to [defaultFleatherEmbedBuilder] .
256286 final FleatherEmbedBuilder embedBuilder;
257287
288+ /// Available configuration for [SpanEmbed] s.
289+ /// If no configuration of found for a [SpanEmbed] , builder will fallback to
290+ /// [embedBuilder] .
291+ ///
292+ /// Defaults to `{}`
293+ final Map <String , FleatherSpanEmbedConfiguration > spanEmbedConfigurations;
294+
258295 /// Configuration that details how spell check should be performed.
259296 ///
260297 /// Specifies the [SpellCheckService] used to spell check text input and the
@@ -331,6 +368,7 @@ class FleatherEditor extends StatefulWidget {
331368 this .clipboardStatus,
332369 this .contextMenuBuilder = defaultContextMenuBuilder,
333370 this .embedBuilder = defaultFleatherEmbedBuilder,
371+ this .spanEmbedConfigurations = const {},
334372 this .linkActionPickerDelegate = defaultLinkActionPickerDelegate,
335373 this .textSelectionControls});
336374
@@ -505,6 +543,7 @@ class _FleatherEditorState extends State<FleatherEditor>
505543 scrollPhysics: widget.scrollPhysics,
506544 onLaunchUrl: widget.onLaunchUrl,
507545 embedBuilder: widget.embedBuilder,
546+ spanEmbedConfigurations: widget.spanEmbedConfigurations,
508547 spellCheckConfiguration: widget.spellCheckConfiguration,
509548 linkActionPickerDelegate: widget.linkActionPickerDelegate,
510549 clipboardManager: widget.clipboardManager,
@@ -618,6 +657,7 @@ class RawEditor extends StatefulWidget {
618657 this .contextMenuBuilder = defaultContextMenuBuilder,
619658 this .spellCheckConfiguration,
620659 this .embedBuilder = defaultFleatherEmbedBuilder,
660+ this .spanEmbedConfigurations = const {},
621661 this .linkActionPickerDelegate = defaultLinkActionPickerDelegate,
622662 }) : assert (maxHeight == null || maxHeight > 0 ),
623663 assert (minHeight == null || minHeight >= 0 ),
@@ -800,6 +840,8 @@ class RawEditor extends StatefulWidget {
800840 /// Defaults to [defaultFleatherEmbedBuilder] .
801841 final FleatherEmbedBuilder embedBuilder;
802842
843+ final Map <String , FleatherSpanEmbedConfiguration > spanEmbedConfigurations;
844+
803845 final LinkActionPickerDelegate linkActionPickerDelegate;
804846
805847 final ClipboardManager clipboardManager;
@@ -1843,6 +1885,7 @@ class RawEditorState extends EditorState
18431885 readOnly: widget.readOnly,
18441886 controller: widget.controller,
18451887 embedBuilder: widget.embedBuilder,
1888+ spanEmbedConfigurations: widget.spanEmbedConfigurations,
18461889 linkActionPicker: _linkActionPicker,
18471890 onLaunchUrl: widget.onLaunchUrl,
18481891 textWidthBasis: widget.textWidthBasis,
@@ -1870,6 +1913,7 @@ class RawEditorState extends EditorState
18701913 ? const EdgeInsets .all (16.0 )
18711914 : null ,
18721915 embedBuilder: widget.embedBuilder,
1916+ spanEmbedConfigurations: widget.spanEmbedConfigurations,
18731917 linkActionPicker: _linkActionPicker,
18741918 onLaunchUrl: widget.onLaunchUrl,
18751919 ),
0 commit comments