Skip to content

Commit d80eb50

Browse files
authored
Merge branch 'main' into opacitymaskview-experiment
2 parents 966d7ef + b71dbf1 commit d80eb50

File tree

5 files changed

+37
-21
lines changed

5 files changed

+37
-21
lines changed

components/MarkdownTextBlock/src/CommunityToolkit.WinUI.Controls.MarkdownTextBlock.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
</ItemGroup>
2222
<ItemGroup>
2323
<!--<PackageReference Include="ColorCode.Core" Version="2.0.14" />-->
24-
<PackageReference Include="HtmlAgilityPack" Version="1.11.48" />
25-
<PackageReference Include="Markdig" Version="0.31.0" />
26-
<PackageReference Include="Roman-Numerals" Version="2.0.0" />
24+
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
25+
<PackageReference Include="Markdig" Version="0.38.0" />
26+
<PackageReference Include="Roman-Numerals" Version="2.0.1" />
2727
</ItemGroup>
2828
<ItemGroup Condition="'$(IsUwp)' == 'true'">
2929
<Using Include="Windows.UI" />

components/MarkdownTextBlock/src/MarkdownTextBlock.xaml.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock.Renderers;
66
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock.TextElements;
77
using Markdig;
8+
using Markdig.Syntax;
89

910
namespace CommunityToolkit.Labs.WinUI.MarkdownTextBlock;
1011

@@ -30,6 +31,12 @@ public partial class MarkdownTextBlock : Control
3031
typeof(MarkdownTextBlock),
3132
new PropertyMetadata(null, OnTextChanged));
3233

34+
private static readonly DependencyProperty MarkdownDocumentProperty = DependencyProperty.Register(
35+
nameof(MarkdownDocument),
36+
typeof(MarkdownDocument),
37+
typeof(MarkdownTextBlock),
38+
new PropertyMetadata(null));
39+
3340
public MarkdownConfig Config
3441
{
3542
get => (MarkdownConfig)GetValue(ConfigProperty);
@@ -42,6 +49,12 @@ public string Text
4249
set => SetValue(TextProperty, value);
4350
}
4451

52+
public MarkdownDocument? MarkdownDocument
53+
{
54+
get => (MarkdownDocument)GetValue(MarkdownDocumentProperty);
55+
private set => SetValue(MarkdownDocumentProperty, value);
56+
}
57+
4558
public event EventHandler<LinkClickedEventArgs>? OnLinkClicked;
4659

4760
internal void RaiseLinkClickedEvent(Uri uri) => OnLinkClicked?.Invoke(this, new LinkClickedEventArgs(uri));
@@ -102,8 +115,8 @@ private void ApplyText(bool rerender)
102115

103116
if (!string.IsNullOrEmpty(Text))
104117
{
105-
var markdown = Markdown.Parse(Text, _pipeline);
106-
_renderer.Render(markdown);
118+
this.MarkdownDocument = Markdown.Parse(Text, _pipeline);
119+
_renderer.Render(this.MarkdownDocument);
107120
}
108121
}
109122
}

components/MarkdownTextBlock/src/MarkdownThemes.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public sealed class MarkdownThemes : DependencyObject
4949

5050
public FontWeight H6FontWeight { get; set; } = FontWeights.Normal;
5151

52-
public Thickness H1Margin { get; set; } = new(0);
53-
public Thickness H2Margin { get; set; } = new(0);
54-
public Thickness H3Margin { get; set; } = new(0);
55-
public Thickness H4Margin { get; set; } = new(0);
56-
public Thickness H5Margin { get; set; } = new(0);
57-
public Thickness H6Margin { get; set; } = new(0);
52+
public Thickness H1Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
53+
public Thickness H2Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
54+
public Thickness H3Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
55+
public Thickness H4Margin { get; set; } = new(left: 0, top: 14, right: 0, bottom: 0);
56+
public Thickness H5Margin { get; set; } = new(left: 0, top: 8, right: 0, bottom: 0);
57+
public Thickness H6Margin { get; set; } = new(left: 0, top: 8, right: 0, bottom: 0);
5858

5959
public Brush InlineCodeBackground { get; set; } = (Brush)Application.Current.Resources["ExpanderHeaderBackground"];
6060
public Brush InlineCodeForeground { get; set; } = (Brush)Application.Current.Resources["TextFillColorPrimaryBrush"];

components/MarkdownTextBlock/src/TextElements/MyList.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ public MyList(ListBlock listBlock)
4545
}
4646

4747
_stackPanel.Orientation = Orientation.Vertical;
48+
_stackPanel.Margin = new Thickness(left: 0, top: 8, right: 0, bottom: 8);
4849
_container.Child = _stackPanel;
4950
_paragraph.Inlines.Add(_container);
5051
}
5152

5253
public void AddChild(IAddChild child)
5354
{
5455
var grid = new Grid();
55-
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
56+
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20, GridUnitType.Pixel) });
57+
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10, GridUnitType.Pixel) });
5658
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
5759
string bullet;
5860
if (_isOrdered)
@@ -79,11 +81,12 @@ public void AddChild(IAddChild child)
7981
};
8082
textBlock.SetValue(Grid.ColumnProperty, 0);
8183
textBlock.VerticalAlignment = VerticalAlignment.Top;
84+
textBlock.TextAlignment = TextAlignment.Right;
8285
grid.Children.Add(textBlock);
8386
var flowDoc = new MyFlowDocument();
8487
flowDoc.AddChild(child);
8588

86-
flowDoc.RichTextBlock.SetValue(Grid.ColumnProperty, 1);
89+
flowDoc.RichTextBlock.SetValue(Grid.ColumnProperty, 2);
8790
flowDoc.RichTextBlock.Padding = new Thickness(0);
8891
flowDoc.RichTextBlock.VerticalAlignment = VerticalAlignment.Top;
8992
grid.Children.Add(flowDoc.RichTextBlock);

components/MarkdownTextBlock/src/TextElements/MyThematicBreak.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public MyThematicBreak(ThematicBreakBlock thematicBreakBlock)
2222
_paragraph = new Paragraph();
2323

2424
var inlineUIContainer = new InlineUIContainer();
25-
var border = new Border();
26-
border.Width = 500;
27-
border.BorderThickness = new Thickness(1);
28-
border.Margin = new Thickness(0, 4, 0, 4);
29-
border.BorderBrush = new SolidColorBrush(Colors.Gray);
30-
border.Height = 1;
31-
border.HorizontalAlignment = HorizontalAlignment.Stretch;
32-
inlineUIContainer.Child = border;
25+
Line line = new Line
26+
{
27+
Stretch = Stretch.Fill,
28+
Stroke = new SolidColorBrush(Colors.Gray),
29+
X2 = 1,
30+
Margin = new Thickness(0, 12, 0, 12)
31+
};
32+
inlineUIContainer.Child = line;
3333
_paragraph.Inlines.Add(inlineUIContainer);
3434
}
3535

0 commit comments

Comments
 (0)