whistyun / MdXaml

Markdown for WPF - alternate version of Markdown.Xaml
MIT License
245 stars 37 forks source link

Spoilers support (details) #61

Closed LevYas closed 1 year ago

LevYas commented 1 year ago

Hello again!

Is it possible to make spoilers? I tried this syntax, but it didn't work:

<details>
  <summary>Spoiler warning</summary>

  Spoiler text. 

</details>

It works here:

Spoiler warning Spoiler text.

I tried with and without the MdXaml.Html plugin, and the result is the same.

whistyun commented 1 year ago

MdXaml.Html 1.19.0 has been released. It enabled details tag.

image
image

LevYas commented 1 year ago

Wow, excellent, thank you! One nitpick though, is it possible to make the whole spoiler summary clickable? Right now only the round with the arrow is clickable. I noticed, that this could be fixed by adding to the file DetailsParser.cs a line 83 with the content viewer.IsHitTestVisible = false; but I'm not aware of the project's specifics so I decided to consult with you. This can break links in the summary, but I think it's expected for the summaries. Github just disables links in summary:

<details>
  <summary>Spoiler warning  [Go to Google!](https://www.google.com)</summary>

  Spoiler text. 

</details>
Spoiler warning [Go to Google!](https://www.google.com) Spoiler text.
whistyun commented 1 year ago

Thank you for trying the feature. I tried your proposal, and realized that a link element on the summary is clickable. So I will change most part of spoiler summary is clickable, but not some of it (e.g., link takes precedence over summary)

sample

<details>
<summary>Spoiler warning <a href="https://www.google.com">link</a>
</summary>
Spoiler text. Spoiler warning 
</details>
Spoiler warning link Spoiler text. Spoiler warning

demonstration

clickaction

whistyun commented 1 year ago

MdXaml 1.19.1 has been released. It enables spoiler header clicking to open and close details.

LevYas commented 1 year ago

Awesome, thank you for the improvement! One more nitpick 😄: Is it possible to make the cursor a regular arrow? The header is not selectable anyway and the "Text Selector" cursor is a little bit misleading. Overall, it's already ready to use, thanks a ton :)

whistyun commented 1 year ago

Is it possible to make the cursor a regular arrow?

I released MdXaml 1.19.2 to fix it.

LevYas commented 1 year ago

Awesome, works great, thank you!