CommunityToolkit / Labs-Windows

A safe space to collaborate and engineer solutions from the prototyping stage all the way through polished finalized component for the Windows Community Toolkit.
Other
347 stars 51 forks source link

MarkdownTextBlock: add alternative to Text property to pass in a MarkdownDocument to the control #596

Open jcoc611-microsoft opened 2 weeks ago

jcoc611-microsoft commented 2 weeks ago

Currently, the only way to set the content of a MarkdownTextBlock is via the Text property, which internally uses Markdown.Parse to convert to a MarkdownDocument. It would be nice to also allow users to pass in an existing MarkdownDocument as an alternative.   Example:

<controls:MarkdownTextBlock
  MarkdownDocument="{x:Bind Doc, Mode=OneTime}" />

Benefits:

jcoc611-microsoft commented 2 days ago

Thinking about it more, I think it is actually better to expose the control's MarkdownDocument rather than allowing users to pass one in.

Users can insert arbitrary logic after Markdown.Parse(...)

This should only be done via Markdig extensions. We will provide different extensibility mechanisms which also allow for implementing custom renderers for the outputs of the extensions.

Users can provide a custom Markdown pipeline

This is not really desired in general, other than extensions.

Users can preserve the MarkdownDocument for other operations

The control owns the MarkdownDocument and users can just access it directly

TBD: add an event for when parsing is done (before this, accessing MarkdownDocument is not valid, and it would be null)