Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- always provide origin text to LinkableElement #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/email.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class EmailLinkifier extends Linkifier {
// Always humanize emails
list.add(EmailElement(
match.group(2)!.replaceFirst(RegExp(r'mailto:'), ''),
match.group(2)
));
}

Expand All @@ -50,7 +51,7 @@ class EmailLinkifier extends Linkifier {
class EmailElement extends LinkableElement {
final String emailAddress;

EmailElement(this.emailAddress) : super(emailAddress, 'mailto:$emailAddress');
EmailElement(this.emailAddress, String? originText) : super(emailAddress, 'mailto:$emailAddress', originText);

@override
String toString() {
Expand Down
6 changes: 4 additions & 2 deletions lib/src/phone_number.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class PhoneNumberLinkifier extends Linkifier {

if (match.group(2)?.isNotEmpty == true) {
list.add(PhoneNumberElement(
match.group(2)!.replaceFirst(RegExp(r'tel:'), ''),
match.group(2)!.replaceFirst(RegExp(r'tel:'), ''),
match.group(2)
));
}

Expand All @@ -49,10 +50,11 @@ class PhoneNumberLinkifier extends Linkifier {
class PhoneNumberElement extends LinkableElement {
final String phoneNumber;

PhoneNumberElement(this.phoneNumber)
PhoneNumberElement(this.phoneNumber, String? originText)
: super(
phoneNumber,
'tel:$phoneNumber',
originText,
);

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/user_tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class UserTagLinkifier extends Linkifier {
}

if (match?.group(2)?.isNotEmpty == true) {
list.add(UserTagElement('@${match!.group(2)!}'));
list.add(UserTagElement('@${match!.group(2)!}', match!.group(2)));
}

if (text.isNotEmpty) {
Expand All @@ -60,7 +60,7 @@ class UserTagLinkifier extends Linkifier {
class UserTagElement extends LinkableElement {
final String userTag;

UserTagElement(this.userTag) : super(userTag, userTag);
UserTagElement(this.userTag, String? originText) : super(userTag, userTag, originText);

@override
String toString() {
Expand Down