@@ -79,6 +79,19 @@ 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+ final PlaceholderAlignment placeholderAlignment;
91+ final TextBaseline ? textBaseline;
92+ final TextStyle ? textStyle;
93+ }
94+
8295/// Default implementation of a builder function for embeddable objects in
8396/// Fleather.
8497///
@@ -255,6 +268,13 @@ class FleatherEditor extends StatefulWidget {
255268 /// Defaults to [defaultFleatherEmbedBuilder] .
256269 final FleatherEmbedBuilder embedBuilder;
257270
271+ /// Available configuration for [SpanEmbed] s.
272+ /// If no configuration of found for a [SpanEmbed] , builder will fallback to
273+ /// [embedBuilder] .
274+ ///
275+ /// Defaults to `{}`
276+ final Map <String , FleatherSpanEmbedConfiguration > spanEmbedConfigs;
277+
258278 /// Configuration that details how spell check should be performed.
259279 ///
260280 /// Specifies the [SpellCheckService] used to spell check text input and the
@@ -331,6 +351,7 @@ class FleatherEditor extends StatefulWidget {
331351 this .clipboardStatus,
332352 this .contextMenuBuilder = defaultContextMenuBuilder,
333353 this .embedBuilder = defaultFleatherEmbedBuilder,
354+ this .spanEmbedConfigs = const {},
334355 this .linkActionPickerDelegate = defaultLinkActionPickerDelegate,
335356 this .textSelectionControls});
336357
@@ -505,6 +526,7 @@ class _FleatherEditorState extends State<FleatherEditor>
505526 scrollPhysics: widget.scrollPhysics,
506527 onLaunchUrl: widget.onLaunchUrl,
507528 embedBuilder: widget.embedBuilder,
529+ spanEmbedConfigurations: widget.spanEmbedConfigs,
508530 spellCheckConfiguration: widget.spellCheckConfiguration,
509531 linkActionPickerDelegate: widget.linkActionPickerDelegate,
510532 clipboardManager: widget.clipboardManager,
@@ -618,6 +640,7 @@ class RawEditor extends StatefulWidget {
618640 this .contextMenuBuilder = defaultContextMenuBuilder,
619641 this .spellCheckConfiguration,
620642 this .embedBuilder = defaultFleatherEmbedBuilder,
643+ this .spanEmbedConfigurations = const {},
621644 this .linkActionPickerDelegate = defaultLinkActionPickerDelegate,
622645 }) : assert (maxHeight == null || maxHeight > 0 ),
623646 assert (minHeight == null || minHeight >= 0 ),
@@ -800,6 +823,8 @@ class RawEditor extends StatefulWidget {
800823 /// Defaults to [defaultFleatherEmbedBuilder] .
801824 final FleatherEmbedBuilder embedBuilder;
802825
826+ final Map <String , FleatherSpanEmbedConfiguration > spanEmbedConfigurations;
827+
803828 final LinkActionPickerDelegate linkActionPickerDelegate;
804829
805830 final ClipboardManager clipboardManager;
@@ -1835,6 +1860,7 @@ class RawEditorState extends EditorState
18351860 readOnly: widget.readOnly,
18361861 controller: widget.controller,
18371862 embedBuilder: widget.embedBuilder,
1863+ spanEmbedConfigurations: widget.spanEmbedConfigurations,
18381864 linkActionPicker: _linkActionPicker,
18391865 onLaunchUrl: widget.onLaunchUrl,
18401866 textWidthBasis: widget.textWidthBasis,
@@ -1862,6 +1888,7 @@ class RawEditorState extends EditorState
18621888 ? const EdgeInsets .all (16.0 )
18631889 : null ,
18641890 embedBuilder: widget.embedBuilder,
1891+ spanEmbedConfigurations: widget.spanEmbedConfigurations,
18651892 linkActionPicker: _linkActionPicker,
18661893 onLaunchUrl: widget.onLaunchUrl,
18671894 ),
0 commit comments