Use AvaloniaEdit
This commit is contained in:
parent
2b2dca2a38
commit
bc72d46bb3
5 changed files with 26 additions and 8 deletions
|
|
@ -8,6 +8,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersionBase)" />
|
||||
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="12.0.0" />
|
||||
<PackageVersion Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersionBase)" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersionBase)" />
|
||||
<PackageVersion Include="Avalonia.Browser" Version="$(AvaloniaVersionBase)" />
|
||||
|
|
|
|||
|
|
@ -11,5 +11,6 @@
|
|||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" />
|
||||
<PackageReference Include="Avalonia.AvaloniaEdit" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" />
|
||||
<PackageReference Include="AvaloniaUI.DiagnosticsSupport">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Yavsc.Blogspot;
|
|||
using Yavsc.Api.Client;
|
||||
using Yavsc.Abstract.Files;
|
||||
using PostIt.Helpers;
|
||||
using AvaloniaEdit.Document;
|
||||
|
||||
namespace PostIt.ViewModels;
|
||||
|
||||
|
|
@ -36,8 +37,19 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
|
|||
|
||||
/// <summary>Editor buffer for the post body. Same pattern as
|
||||
/// <see cref="DraftTitle"/>.</summary>
|
||||
|
||||
public string DraftArticle
|
||||
{
|
||||
get => DraftArticleDocument.Text;
|
||||
set {
|
||||
OnPropertyChanging(nameof(DraftArticle));
|
||||
DraftArticleDocument = new TextDocument(value);
|
||||
this.OnPropertyChanged(nameof(DraftArticle));
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string DraftArticle { get; set; }
|
||||
public partial TextDocument DraftArticleDocument {get; set;}
|
||||
|
||||
/// <summary>Editor buffer for the post's publication state.
|
||||
/// Reflects the server-side <c>IsPublished</c> flag (the
|
||||
|
|
@ -381,6 +393,7 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
|
|||
WindowTitle = "PostIt";
|
||||
DraftTitle = string.Empty;
|
||||
DraftArticle = string.Empty;
|
||||
|
||||
DraftIsPublished = false;
|
||||
IsLoaded = false;
|
||||
// Production path: DI injects the canonical Settings singleton
|
||||
|
|
@ -464,7 +477,6 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
|
|||
// enable as soon as the user has typed a non-whitespace
|
||||
// title, regardless of whether a post is selected.
|
||||
partial void OnDraftTitleChanged(string value) => SaveCommand.NotifyCanExecuteChanged();
|
||||
partial void OnDraftArticleChanged(string value) => SaveCommand.NotifyCanExecuteChanged();
|
||||
|
||||
|
||||
private async Task RefreshPostsAsync()
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:PostIt.ViewModels"
|
||||
xmlns:postitControls="using:PostIt.Controls"
|
||||
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||
xmlns:models="using:Yavsc.Blogspot"
|
||||
xmlns:views="using:PostIt.Views.Blogs"
|
||||
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||
xmlns:md="using:MarkdownViewer.Core.Controls"
|
||||
mc:Ignorable="d"
|
||||
x:Class="PostIt.Views.Blogs.BlogsPage"
|
||||
|
|
@ -132,11 +132,14 @@
|
|||
<TextBlock Grid.Row="0" Text="Post detail" FontWeight="SemiBold" />
|
||||
<TextBox x:Name="DraftTitleTextBox"
|
||||
Grid.Row="1" Text="{Binding DraftTitle, Mode=TwoWay}" PlaceholderText="Title" />
|
||||
<TextBox Grid.Row="2" PlaceholderText="Write something here !"
|
||||
Text="{Binding DraftArticle, Mode=TwoWay}"
|
||||
MinHeight="320"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch" />
|
||||
|
||||
<AvaloniaEdit:TextEditor
|
||||
Grid.Row="2" VerticalAlignment="Stretch"
|
||||
|
||||
Document="{Binding DraftArticleDocument, Mode=TwoWay}"
|
||||
ShowLineNumbers="True"
|
||||
FontFamily="Cascadia Code,Consolas,Menlo,Monospace"/>
|
||||
|
||||
|
||||
<Border Grid.Row="3" BorderBrush="LightGray" BorderThickness="1" Padding="8">
|
||||
<StackPanel Spacing="4">
|
||||
|
|
|
|||
Loading…
Reference in a new issue