-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathMarkdownTextBlock.Properties.cs
More file actions
232 lines (205 loc) · 7.75 KB
/
MarkdownTextBlock.Properties.cs
File metadata and controls
232 lines (205 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// 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.
using Markdig.Syntax;
namespace CommunityToolkit.WinUI.Controls;
public partial class MarkdownTextBlock
{
/// <summary>
/// Identifies the <see cref="Config"/> dependency property.
/// </summary>
private static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(
nameof(Config),
typeof(MarkdownConfig),
typeof(MarkdownTextBlock),
PropertyMetadata.Create(() => MarkdownConfig.Default, OnConfigChanged)
);
/// <summary>
/// Identifies the <see cref="Text"/> dependency property.
/// </summary>
private static readonly DependencyProperty TextProperty = DependencyProperty.Register(
nameof(Text),
typeof(string),
typeof(MarkdownTextBlock),
new PropertyMetadata(null, OnTextChanged));
/// <summary>
/// Identifies the <see cref="UseEmphasisExtras"/> dependency property.
/// </summary>
private static readonly DependencyProperty UseEmphasisExtrasProperty = DependencyProperty.Register(
nameof(UseEmphasisExtras),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="UsePipeTables"/> dependency property.
/// </summary>
private static readonly DependencyProperty UsePipeTablesProperty = DependencyProperty.Register(
nameof(UsePipeTables),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="UseListExtras"/> dependency property.
/// </summary>
private static readonly DependencyProperty UseListExtrasProperty = DependencyProperty.Register(
nameof(UseListExtras),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="UseTaskLists"/> dependency property.
/// </summary>
private static readonly DependencyProperty UseTaskListsProperty = DependencyProperty.Register(
nameof(UseTaskLists),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="UseAutoLinks"/> dependency property.
/// </summary>
private static readonly DependencyProperty UseAutoLinksProperty = DependencyProperty.Register(
nameof(UseAutoLinks),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="DisableHtmlProperty"/> dependency property.
/// </summary>
private static readonly DependencyProperty DisableHtmlProperty = DependencyProperty.Register(
nameof(DisableHtmlProperty),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="DisableLinksProperty"/> dependency property.
/// </summary>
private static readonly DependencyProperty DisableLinksProperty = DependencyProperty.Register(
nameof(DisableLinksProperty),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="UseSoftlineBreakAsHardlineBreak"/> dependency property.
/// </summary>
private static readonly DependencyProperty UseSoftlineBreakAsHardlineBreakProperty = DependencyProperty.Register(
nameof(UseSoftlineBreakAsHardlineBreak),
typeof(bool),
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));
/// <summary>
/// Identifies the <see cref="IsTextSelectionEnabled"/> dependency property.
/// </summary>
private static readonly DependencyProperty IsTextSelectionEnabledProperty = DependencyProperty.Register(
nameof(IsTextSelectionEnabled),
typeof(bool),
typeof(MarkdownTextBlock),
new PropertyMetadata(false, OnIsTextSelectionEnabledChanged));
private static void OnIsTextSelectionEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is MarkdownTextBlock mtb && mtb._document != null)
{
mtb._document.RichTextBlock.IsTextSelectionEnabled = (bool)e.NewValue;
}
}
public MarkdownConfig Config
{
get => (MarkdownConfig)GetValue(ConfigProperty);
set => SetValue(ConfigProperty, value);
}
/// <summary>
/// Gets or sets the markdown text to display.
/// </summary>
public string Text
{
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
/// <summary>
/// If true, adds support for strikethroughs, superscript, subscript, inserted, and marked text.
/// </summary>
public bool UseEmphasisExtras
{
get => (bool)GetValue(UseEmphasisExtrasProperty);
set => SetValue(UseEmphasisExtrasProperty, value);
}
/// <summary>
/// If true, adds support for GitHub-style pipe tables.
/// </summary>
public bool UsePipeTables
{
get => (bool)GetValue(UsePipeTablesProperty);
set => SetValue(UsePipeTablesProperty, value);
}
/// <summary>
/// If true, adds support for alphabetic and roman numbering in lists.
/// </summary>
public bool UseListExtras
{
get => (bool)GetValue(UseListExtrasProperty);
set => SetValue(UseListExtrasProperty, value);
}
/// <summary>
/// If true, adds support for GitHub-style task lists using the [ ] and [x] syntax.
/// </summary>
public bool UseTaskLists
{
get => (bool)GetValue(UseTaskListsProperty);
set => SetValue(UseTaskListsProperty, value);
}
/// <summary>
/// If true, parses text that looks like URIs into hyperlinks (e.g. https://...).
/// </summary>
public bool UseAutoLinks
{
get => (bool)GetValue(UseAutoLinksProperty);
set => SetValue(UseAutoLinksProperty, value);
}
/// <summary>
/// If true, Disables HTML parsing.
/// </summary>
public bool DisableHtml
{
get => (bool)GetValue(DisableHtmlProperty);
set => SetValue(DisableHtmlProperty, value);
}
/// <summary>
/// If true, Disables link parsing.
/// </summary>
public bool DisableLinks
{
get => (bool)GetValue(DisableLinksProperty);
set => SetValue(DisableLinksProperty, value);
}
/// <summary>
/// If true, considers single newlines as hardline breaks.
/// </summary>
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);
}
/// <summary>
/// Gets or sets a value indicating whether text selection is enabled.
/// </summary>
public bool IsTextSelectionEnabled
{
get => (bool)GetValue(IsTextSelectionEnabledProperty);
set => SetValue(IsTextSelectionEnabledProperty, value);
}
}