File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ class FormatMarkdown {
1111 /// String to convert
1212 String data,
1313
14+ /// An alternate data source on which to perform formatting
15+ String ? alternateData,
16+
1417 /// Start index when converting part of [data]
1518 int fromIndex,
1619
@@ -71,7 +74,7 @@ class FormatMarkdown {
7174 break ;
7275 case MarkdownType .blockquote:
7376 var index = 0 ;
74- final splitedData = data.substring (fromIndex, toIndex).split ('\n ' );
77+ final splitedData = (alternateData ?? data.substring (fromIndex, toIndex) ).split ('\n ' );
7578 changedData = splitedData.map ((value) {
7679 index++ ;
7780 return index == splitedData.length ? '> $value ' : '> $value \n ' ;
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ class MarkdownToolbar extends StatelessWidget {
3333 /// Allows overriding tap actions for each [MarkdownType]
3434 final Map <MarkdownType , void Function ()>? customTapActions;
3535
36+ /// A function which allows the widget's parent to provide an alternate text selection
37+ final String ? Function ()? getAlternativeSelection;
38+
3639 /// Constructor for [MarkdownToolbar]
3740 const MarkdownToolbar ({
3841 super .key,
@@ -43,6 +46,7 @@ class MarkdownToolbar extends StatelessWidget {
4346 this .customImageButtonAction,
4447 this .imageIsLoading = false ,
4548 this .customTapActions,
49+ this .getAlternativeSelection,
4650 });
4751
4852 @override
@@ -223,6 +227,7 @@ class MarkdownToolbar extends StatelessWidget {
223227 ResultMarkdown result = FormatMarkdown .convertToMarkdown (
224228 type,
225229 controller.text,
230+ getAlternativeSelection? .call (),
226231 fromIndex,
227232 toIndex,
228233 titleSize: titleSize,
You can’t perform that action at this time.
0 commit comments