Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] Markdig based MarkdownTextBlock #480

Merged
merged 38 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
07a290a
initial commit
nerocui Jun 28, 2023
8f9b56a
fixed dependencies
nerocui Jul 3, 2023
8740ba2
added dependencies in implicit global usings
nerocui Jul 12, 2023
aea15a8
fixed some references
nerocui Jul 13, 2023
9885a12
Remove redundant sample references
niels9001 Jul 13, 2023
2c7d1d7
Remove Uno target heads
niels9001 Jul 13, 2023
cc1f469
Adding file heads and missing namespaces for UWP
niels9001 Jul 13, 2023
ab73827
Surpressing null reference errors
niels9001 Jul 13, 2023
4354e1a
fixed crash
nerocui Jul 13, 2023
52770c0
Fix markdown not showing
niels9001 Jul 13, 2023
0346787
polished the experiment
nerocui Jul 23, 2023
ec05f68
changed name to MarkdownTextBlock
nerocui Jul 23, 2023
e820cb1
fixed xaml theme
nerocui Jul 23, 2023
3474a93
fixed icon issue
nerocui Jul 23, 2023
7f50559
updated description
nerocui Jul 23, 2023
a2cca4f
added back the sample
nerocui Jul 23, 2023
61daa94
added example for task list
nerocui Jul 23, 2023
444dc33
making it StatusAndInfo instead of Layout
nerocui Jul 23, 2023
e3226e7
made requested changes
nerocui Jul 27, 2023
48a3231
bind to textbox instead of a property
nerocui Jul 29, 2023
40ab85d
run styler
nerocui Jul 29, 2023
592ad3c
addressed perf issue
nerocui Jul 30, 2023
daa20c2
fixed code style
nerocui Jul 30, 2023
9cb2cc4
added theme object, abstracted some styling to the theme obj
nerocui Aug 6, 2023
db1b745
clean up
nerocui Aug 6, 2023
5a2f87c
fixed fontweight using statement
nerocui Aug 7, 2023
7bd85b8
removing unused code
nerocui Nov 22, 2023
6e350ee
handled switch statement exhaustively.
nerocui Nov 22, 2023
edcd3ad
Merge branch 'CommunityToolkit:main' into neroc/markdigui
nerocui Jan 16, 2024
a41cbc3
added header
nerocui Jan 17, 2024
54ff320
fixed test failures
nerocui Jan 29, 2024
2b9ec51
Merge branch 'main' into neroc/markdigui
niels9001 Jan 29, 2024
80c8cf2
Update Dependencies.props
nerocui Jan 30, 2024
cdec30b
Revert "Update Dependencies.props"
nerocui Jan 31, 2024
b9afa86
Merge branch 'main' into neroc/markdigui
niels9001 Feb 1, 2024
98de957
commented out colorcode for now
nerocui Feb 3, 2024
d8c9025
Merge branch 'neroc/markdigui' of https://github.com/nerocui/Labs-Win…
nerocui Feb 3, 2024
fa0c518
Update components/MarkdownTextBlock/src/CommunityToolkit.WinUI.Contro…
Arlodotexe Feb 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/MarkdownTextBlock/OpenSolution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

powershell ..\..\tooling\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %*
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions components/MarkdownTextBlock/samples/Dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.

MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.

For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For UWP / WinAppSDK / Uno packages, place the package references here.
-->
<Project>
<!-- WinUI 2 / UWP -->
<ItemGroup Condition="'$(IsUwp)' == 'true'">
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 2 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
</ItemGroup>

<!-- WinUI 3 / WinAppSdk -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 3 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<ToolkitComponentName>MarkdownTextBlock</ToolkitComponentName>
</PropertyGroup>

<!-- Sets this up as a toolkit component's sample project -->
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" />
<ItemGroup>
<None Remove="Assets\MarkdownTextBlock.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\MarkdownTextBlock.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
34 changes: 34 additions & 0 deletions components/MarkdownTextBlock/samples/MarkdownTextBlock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: MarkdownTextBlock
author: nerocui
description: A control for displaying markdown natively.
keywords: MarkdownTextBlock, Control, Layout
dev_langs:
- csharp
category: Controls
subcategory: StatusAndInfo
experimental: true
discussion-id: 0
issue-id: 0
icon: Assets/MarkdownTextBlock.png
---

<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->

<!-- Be sure to update the discussion/issue numbers above with your Labs discussion/issue id numbers in order for UI links to them from the sample app to work. -->

# MarkdownTextBlock

MarkdownTextBlock is a evolution of the existing MarkdownTextBlock in the community toolkit. This new implementation uses the popular [Markdig](https://github.com/xoofx/markdig) library for parsing. This solves some long standing bugs and feature gaps in our existing implementation.

## Templated Controls

The Toolkit is built with templated controls. This provides developers a flexible way to restyle components
easily while still inheriting the general functionality a control provides. The examples below show
how a component can use a default style and then get overridden by the end developer.

> [!Sample MarkdownTextBlockCustomSample]
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="MarkdownTextBlockExperiment.Samples.MarkdownTextBlockCustomSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:MarkdownTextBlockExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="0,0,0,12"
FontSize="16"
FontWeight="Bold"
Text="Try it live!" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:MarkdownTextBlock Grid.Column="0"
Config="{x:Bind LiveMarkdownConfig, Mode=OneTime}"
Text="{x:Bind MarkdownTextBox.Text, Mode=OneWay}" />
<TextBox x:Name="MarkdownTextBox"
Grid.Column="1"
AcceptsReturn="True" />
</Grid>
<TextBlock Grid.Row="2"
Margin="0,0,0,12"
FontSize="16"
FontWeight="Bold"
Text="Built-in Sample" />
<controls:MarkdownTextBlock Grid.Row="3"
Config="{x:Bind MarkdownConfig, Mode=OneTime}"
Text="{x:Bind Text, Mode=OneTime}" />
</Grid>
</Page>
Loading
Loading