Skip to content

Supports text selection, copy button in a code block and header scroll event

Pre-release
Pre-release
Compare
Choose a tag to compare
@whistyun whistyun released this 18 Mar 10:18

Text Selection

MarkdownScrollViewer has new property SelectionEnabled to enable text selection.

<!-- xmlns:md="https://github.com/whistyun/Markdown.Avalonia" -->
<md:MarkdownScrollViewer SelectionEnabled="True"
    ...
    />

copydocument

At the moment, only plain text copies are provided due to functional limitations of the Avalonia.

Copy button in a code block

This package display a lang and copy button.
copycodeblock

A button label can be changed using Style.

<Styles xmlns="https://github.com/avaloniaui">
  <Style Selector=".CodeBlock Button.CopyButton TextBlock">
    <Setter Property="Text" Value="πŸ“‹"/>
  </Style>
</Styles>

image

Header scroll event

MarkdownScrollViewer has new event HeaderScrolled to notify that the header has been scrolled.

MainWindow.axaml:

<!-- xmlns:md="https://github.com/whistyun/Markdown.Avalonia" -->

<Label x:Name="Breadcrumb"
    />

<md:MarkdownScrollViewer
    HeaderScrolled="HeaderScrolled"
    ...
    />

MainWindow.axaml.cs

public partial class MainWindow : Window
{
    private Label _breadcrumb;

    private void HeaderScrolled(object sender, HeaderScrolledEventArgs args)
    {
        _breadcrumb.Content = string.Join(" > ", args.Tree.Select(tag => tag.Text));
    }
}

scrolling