From 4552b3ba171be4518461b37bb7e5a8ed164f6f99 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 12 Jul 2024 23:41:50 +0200 Subject: [PATCH] UI - Fix Markdown link issues --- src/Artemis.UI/ArtemisLinkCommand.cs | 30 +++++++++++++++++++ .../Controls/SplitMarkdownEditor.axaml | 8 +++++ src/Artemis.UI/Screens/Root/RootViewModel.cs | 5 +++- .../Updating/ReleaseDetailsView.axaml | 5 ++++ .../EntryReleases/EntryReleaseView.axaml | 7 +++++ .../Layout/LayoutDescriptionView.axaml | 7 +++++ .../Plugins/PluginDescriptionView.axaml | 7 +++++ .../Profile/ProfileDescriptionView.axaml | 7 +++++ 8 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/Artemis.UI/ArtemisLinkCommand.cs diff --git a/src/Artemis.UI/ArtemisLinkCommand.cs b/src/Artemis.UI/ArtemisLinkCommand.cs new file mode 100644 index 000000000..40adcec5b --- /dev/null +++ b/src/Artemis.UI/ArtemisLinkCommand.cs @@ -0,0 +1,30 @@ +using System; +using System.Windows.Input; +using Artemis.Core; +using Artemis.UI.Shared.Routing; + +namespace Artemis.UI; + +public class ArtemisLinkCommand: ICommand +{ + public static IRouter? Router; + + /// + public bool CanExecute(object? parameter) => true; + + /// + public void Execute(object? parameter) + { + if (parameter is not string url || !Uri.TryCreate(url, UriKind.Absolute, out Uri? uri)) + return; + + if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) + Utilities.OpenUrl(url); + else if (uri.Scheme == "artemis") + Router?.Navigate(uri.Host + uri.LocalPath); + } + + /// + public event EventHandler? CanExecuteChanged; + +} \ No newline at end of file diff --git a/src/Artemis.UI/Controls/SplitMarkdownEditor.axaml b/src/Artemis.UI/Controls/SplitMarkdownEditor.axaml index f99eba062..50f2d0dc2 100644 --- a/src/Artemis.UI/Controls/SplitMarkdownEditor.axaml +++ b/src/Artemis.UI/Controls/SplitMarkdownEditor.axaml @@ -5,8 +5,13 @@ xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit" xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" xmlns:fa="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" + xmlns:input="clr-namespace:System.Windows.Input;assembly=System.ObjectModel" + xmlns:ui="clr-namespace:Artemis.UI" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Controls.SplitMarkdownEditor"> + + +