Skip to content

Commit

Permalink
feat: make latext selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
xushengs committed Feb 19, 2024
1 parent 0ea95fc commit fdb45ff
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/src/latex_element_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import 'package:markdown/markdown.dart' as md;

class LatexElementBuilder extends MarkdownElementBuilder {
TextStyle? textStyle;
bool selectable;

LatexElementBuilder({this.textStyle});
LatexElementBuilder({this.textStyle, this.selectable = false});

@override
Widget visitElementAfterWithContext(BuildContext context, md.Element element,
Expand All @@ -17,10 +18,18 @@ class LatexElementBuilder extends MarkdownElementBuilder {
return const SizedBox();
}

return Math.tex(
text,
mathStyle: displayMode == 'true' ? MathStyle.display : MathStyle.text,
textStyle: textStyle,
);
final mathStyle =
displayMode == 'true' ? MathStyle.display : MathStyle.text;
return selectable
? SelectableMath.tex(
text,
mathStyle: mathStyle,
textStyle: textStyle,
)
: Math.tex(
text,
mathStyle: mathStyle,
textStyle: textStyle,
);
}
}

0 comments on commit fdb45ff

Please sign in to comment.