mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-07-11 00:11:55 +02:00
Add Url property to HyperLink; simplify converter link handling; add http/https scheme guard
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using DiscordChatExporter.Gui.Utils.Extensions;
|
||||
using DiscordChatExporter.Gui.Views.Controls;
|
||||
using Markdig;
|
||||
using Markdig.Syntax;
|
||||
@@ -82,18 +79,16 @@ public class MarkdownToInlinesConverter : IValueConverter
|
||||
break;
|
||||
}
|
||||
|
||||
case LinkInline link when link.Url is not null:
|
||||
case LinkInline link when !string.IsNullOrWhiteSpace(link.Url):
|
||||
{
|
||||
var text = string.Concat(
|
||||
link.OfType<LiteralInline>().Select(l => l.Content.ToString())
|
||||
);
|
||||
var url = link.Url;
|
||||
inlines.Add(
|
||||
new InlineUIContainer(
|
||||
new HyperLink
|
||||
{
|
||||
Text = text,
|
||||
Command = new RelayCommand(() => Process.StartShellExecute(url)),
|
||||
Text = string.Concat(
|
||||
link.OfType<LiteralInline>().Select(l => l.Content.ToString())
|
||||
),
|
||||
Url = link.Url,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user