Skip to content

Commit

Permalink
Merge branch 'main' into user/juosori/ConfigureBuiltInExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Osorio committed Nov 29, 2024
2 parents 0fa9333 + b71dbf1 commit 10cc885
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions components/MarkdownTextBlock/src/MarkdownTextBlock.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Markdig.Syntax;

namespace CommunityToolkit.Labs.WinUI.MarkdownTextBlock;

public partial class MarkdownTextBlock
Expand Down Expand Up @@ -79,6 +81,15 @@ public partial class MarkdownTextBlock
typeof(MarkdownTextBlock),
new PropertyMetadata(false));

/// <summary>
/// Identifies the <see cref="MarkdownDocument"/> dependency property.
/// </summary>
private static readonly DependencyProperty MarkdownDocumentProperty = DependencyProperty.Register(
nameof(MarkdownDocument),
typeof(MarkdownDocument),
typeof(MarkdownTextBlock),
new PropertyMetadata(null));

public MarkdownConfig Config
{
get => (MarkdownConfig)GetValue(ConfigProperty);
Expand Down Expand Up @@ -147,4 +158,13 @@ public bool UseSoftlineBreakAsHardlineBreak
get => (bool)GetValue(UseSoftlineBreakAsHardlineBreakProperty);
set => SetValue(UseSoftlineBreakAsHardlineBreakProperty, value);
}

/// <summary>
/// Gets the parsed markdown document. May be null if the document has not been parsed yet.
/// </summary>
public MarkdownDocument? MarkdownDocument
{
get => (MarkdownDocument)GetValue(MarkdownDocumentProperty);
private set => SetValue(MarkdownDocumentProperty, value);
}
}
5 changes: 3 additions & 2 deletions components/MarkdownTextBlock/src/MarkdownTextBlock.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock.Renderers.ObjectRenderers.Inlines;
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock.TextElements;
using Markdig;
using Markdig.Syntax;

namespace CommunityToolkit.Labs.WinUI.MarkdownTextBlock;

Expand Down Expand Up @@ -87,8 +88,8 @@ private void ApplyText(bool rerender)

if (!string.IsNullOrEmpty(Text))
{
var markdown = Markdown.Parse(Text, _pipeline);
_renderer.Render(markdown);
this.MarkdownDocument = Markdown.Parse(Text, _pipeline);
_renderer.Render(this.MarkdownDocument);
}
}
}
Expand Down

0 comments on commit 10cc885

Please sign in to comment.