Skip to content

Commit 10cc885

Browse files
author
Juan Osorio
committed
Merge branch 'main' into user/juosori/ConfigureBuiltInExtensions
2 parents 0fa9333 + b71dbf1 commit 10cc885

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

components/MarkdownTextBlock/src/MarkdownTextBlock.Properties.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using Markdig.Syntax;
6+
57
namespace CommunityToolkit.Labs.WinUI.MarkdownTextBlock;
68

79
public partial class MarkdownTextBlock
@@ -79,6 +81,15 @@ public partial class MarkdownTextBlock
7981
typeof(MarkdownTextBlock),
8082
new PropertyMetadata(false));
8183

84+
/// <summary>
85+
/// Identifies the <see cref="MarkdownDocument"/> dependency property.
86+
/// </summary>
87+
private static readonly DependencyProperty MarkdownDocumentProperty = DependencyProperty.Register(
88+
nameof(MarkdownDocument),
89+
typeof(MarkdownDocument),
90+
typeof(MarkdownTextBlock),
91+
new PropertyMetadata(null));
92+
8293
public MarkdownConfig Config
8394
{
8495
get => (MarkdownConfig)GetValue(ConfigProperty);
@@ -147,4 +158,13 @@ public bool UseSoftlineBreakAsHardlineBreak
147158
get => (bool)GetValue(UseSoftlineBreakAsHardlineBreakProperty);
148159
set => SetValue(UseSoftlineBreakAsHardlineBreakProperty, value);
149160
}
161+
162+
/// <summary>
163+
/// Gets the parsed markdown document. May be null if the document has not been parsed yet.
164+
/// </summary>
165+
public MarkdownDocument? MarkdownDocument
166+
{
167+
get => (MarkdownDocument)GetValue(MarkdownDocumentProperty);
168+
private set => SetValue(MarkdownDocumentProperty, value);
169+
}
150170
}

components/MarkdownTextBlock/src/MarkdownTextBlock.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock.Renderers.ObjectRenderers.Inlines;
99
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock.TextElements;
1010
using Markdig;
11+
using Markdig.Syntax;
1112

1213
namespace CommunityToolkit.Labs.WinUI.MarkdownTextBlock;
1314

@@ -87,8 +88,8 @@ private void ApplyText(bool rerender)
8788

8889
if (!string.IsNullOrEmpty(Text))
8990
{
90-
var markdown = Markdown.Parse(Text, _pipeline);
91-
_renderer.Render(markdown);
91+
this.MarkdownDocument = Markdown.Parse(Text, _pipeline);
92+
_renderer.Render(this.MarkdownDocument);
9293
}
9394
}
9495
}

0 commit comments

Comments
 (0)