saminsohag

change onLinkTab to onLinkTap

## 1.1.0
* Changed `onLinkTab` to `onLinkTap` fixed issues of newLine issues.
## 1.0.20
* Fix: support balanced parentheses in image and link URLs. [#68](https://github.com/Infinitix-LLC/gpt_markdown/pull/68)
... ...
... ... @@ -76,6 +76,10 @@ class _MyHomePageState extends State<MyHomePage> {
TextDirection _direction = TextDirection.ltr;
final TextEditingController _controller = TextEditingController(
text: r'''
decsiob (*) is on the set PQ = {91, 905} jjjzjsx * jjdbhsjsjmamajmsghdhhi msnnsjnskaksjjshahsh
(*)
This is a sample markdown document.
* **bold**
... ... @@ -444,7 +448,7 @@ This document was created to test the robustness of Markdown parsers and to ensu
Widget child = GptMarkdown(
_controller.text,
textDirection: _direction,
onLinkTab: (url, title) {
onLinkTap: (url, title) {
debugPrint(url);
debugPrint(title);
},
... ... @@ -615,40 +619,40 @@ This document was created to test the robustness of Markdown parsers and to ensu
),
);
},
components: [
CodeBlockMd(),
NewLines(),
BlockQuote(),
ImageMd(),
ATagMd(),
TableMd(),
HTag(),
UnOrderedList(),
OrderedList(),
RadioButtonMd(),
CheckBoxMd(),
HrLine(),
StrikeMd(),
BoldMd(),
ItalicMd(),
LatexMath(),
LatexMathMultiLine(),
HighlightedText(),
SourceTag(),
IndentMd(),
],
inlineComponents: [
ImageMd(),
ATagMd(),
TableMd(),
StrikeMd(),
BoldMd(),
ItalicMd(),
LatexMath(),
LatexMathMultiLine(),
HighlightedText(),
SourceTag(),
],
// components: [
// CodeBlockMd(),
// NewLines(),
// BlockQuote(),
// ImageMd(),
// ATagMd(),
// TableMd(),
// HTag(),
// UnOrderedList(),
// OrderedList(),
// RadioButtonMd(),
// CheckBoxMd(),
// HrLine(),
// StrikeMd(),
// BoldMd(),
// ItalicMd(),
// LatexMath(),
// LatexMathMultiLine(),
// HighlightedText(),
// SourceTag(),
// IndentMd(),
// ],
// inlineComponents: [
// ImageMd(),
// ATagMd(),
// TableMd(),
// StrikeMd(),
// BoldMd(),
// ItalicMd(),
// LatexMath(),
// LatexMathMultiLine(),
// HighlightedText(),
// SourceTag(),
// ],
// codeBuilder: (context, name, code, closed) {
// return Padding(
// padding: const EdgeInsets.symmetric(
... ...
... ... @@ -61,12 +61,12 @@ typedef ImageBuilder = Widget Function(BuildContext context, String imageUrl);
/// The [GptMarkdownConfig] class is used to configure the GPT Markdown component.
/// It takes a [style] parameter to set the style of the text,
/// a [textDirection] parameter to set the direction of the text,
/// and an optional [onLinkTab] parameter to handle link clicks.
/// and an optional [onLinkTap] parameter to handle link clicks.
class GptMarkdownConfig {
const GptMarkdownConfig({
this.style,
this.textDirection = TextDirection.ltr,
this.onLinkTab,
this.onLinkTap,
this.textAlign,
this.textScaler,
this.latexWorkaround,
... ... @@ -98,7 +98,7 @@ class GptMarkdownConfig {
final TextScaler? textScaler;
/// The callback function to handle link clicks.
final void Function(String url, String title)? onLinkTab;
final void Function(String url, String title)? onLinkTap;
/// The LaTeX workaround.
final String Function(String tex)? latexWorkaround;
... ... @@ -146,7 +146,7 @@ class GptMarkdownConfig {
GptMarkdownConfig copyWith({
TextStyle? style,
TextDirection? textDirection,
final void Function(String url, String title)? onLinkTab,
final void Function(String url, String title)? onLinkTap,
final TextAlign? textAlign,
final TextScaler? textScaler,
final String Function(String tex)? latexWorkaround,
... ... @@ -167,7 +167,7 @@ class GptMarkdownConfig {
return GptMarkdownConfig(
style: style ?? this.style,
textDirection: textDirection ?? this.textDirection,
onLinkTab: onLinkTab ?? this.onLinkTab,
onLinkTap: onLinkTap ?? this.onLinkTap,
textAlign: textAlign ?? this.textAlign,
textScaler: textScaler ?? this.textScaler,
latexWorkaround: latexWorkaround ?? this.latexWorkaround,
... ... @@ -218,7 +218,7 @@ class GptMarkdownConfig {
// linkBuilder == other.linkBuilder &&
// imageBuilder == other.imageBuilder &&
// highlightBuilder == other.highlightBuilder &&
// onLinkTab == other.onLinkTab &&
// onLinkTap == other.onLinkTap &&
textDirection == other.textDirection;
}
}
... ...
... ... @@ -30,7 +30,7 @@ class GptMarkdown extends StatelessWidget {
this.textAlign,
this.imageBuilder,
this.textScaler,
this.onLinkTab,
this.onLinkTap,
this.latexBuilder,
this.codeBuilder,
this.sourceTagBuilder,
... ... @@ -61,7 +61,7 @@ class GptMarkdown extends StatelessWidget {
final TextScaler? textScaler;
/// The callback function to handle link clicks.
final void Function(String url, String title)? onLinkTab;
final void Function(String url, String title)? onLinkTap;
/// The LaTeX workaround.
final String Function(String tex)? latexWorkaround;
... ... @@ -185,7 +185,7 @@ class GptMarkdown extends StatelessWidget {
config: GptMarkdownConfig(
textDirection: textDirection,
style: style,
onLinkTab: onLinkTab,
onLinkTap: onLinkTap,
textAlign: textAlign,
textScaler: textScaler,
followLinkColor: followLinkColor,
... ...
... ... @@ -2,12 +2,11 @@ part of 'gpt_markdown.dart';
/// Markdown components
abstract class MarkdownComponent {
static final List<MarkdownComponent> components = [
static List<MarkdownComponent> get globalComponents => [
CodeBlockMd(),
LatexMathMultiLine(),
NewLines(),
BlockQuote(),
ImageMd(),
ATagMd(),
TableMd(),
HTag(),
UnOrderedList(),
... ... @@ -15,13 +14,6 @@ abstract class MarkdownComponent {
RadioButtonMd(),
CheckBoxMd(),
HrLine(),
StrikeMd(),
BoldMd(),
ItalicMd(),
LatexMath(),
LatexMathMultiLine(),
HighlightedText(),
SourceTag(),
IndentMd(),
];
... ... @@ -47,7 +39,7 @@ abstract class MarkdownComponent {
) {
var components =
includeGlobalComponents
? config.components ?? MarkdownComponent.components
? config.components ?? MarkdownComponent.globalComponents
: config.inlineComponents ?? MarkdownComponent.inlineComponents;
List<InlineSpan> spans = [];
Iterable<String> regexes = components.map<String>((e) => e.exp.pattern);
... ... @@ -75,6 +67,14 @@ abstract class MarkdownComponent {
return "";
},
onNonMatch: (p0) {
if (p0.isEmpty) {
return "";
}
if (includeGlobalComponents) {
var newSpans = generate(context, p0, config.copyWith(), false);
spans.addAll(newSpans);
return "";
}
spans.add(TextSpan(text: p0, style: config.style));
return "";
},
... ... @@ -830,7 +830,7 @@ class ATagMd extends InlineMd {
if (builder != null) {
return WidgetSpan(
child: GestureDetector(
onTap: () => config.onLinkTab?.call(url, linkText),
onTap: () => config.onLinkTap?.call(url, linkText),
child: builder(
context,
linkText,
... ... @@ -848,7 +848,7 @@ class ATagMd extends InlineMd {
hoverColor: theme.linkHoverColor,
color: theme.linkColor,
onPressed: () {
config.onLinkTab?.call(url, linkText);
config.onLinkTap?.call(url, linkText);
},
text: linkText,
config: config,
... ...
name: gpt_markdown
description: "Powerful Markdown & LaTeX Renderer for Flutter: Rich Text, Math, Tables, Links, and Text Selection. Ideal for ChatGPT, Gemini, and more."
version: 1.0.20
version: 1.1.0
homepage: https://github.com/Infinitix-LLC/gpt_markdown
environment:
... ...