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

Add sanitized markdown support for epoch statement #1631

Merged
merged 6 commits into from Nov 8, 2022

Conversation

sshmm
Copy link
Contributor

@sshmm sshmm commented Nov 5, 2022

Motivation and Context

resolves #1563

Description

1- Add sanitized markdown support for epoch statement. The markdown will be displayed in place of text on Blur
2- used @uiw/react-markdown-preview to support display markdown
3- used skipHtml={false} to skip html rendering

Test and Deployment Plan

1- Go to Contribution page write epoch statement with markdown. click outside the text area to display

Screenshots (if appropriate):

image

@vercel
Copy link

vercel bot commented Nov 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
coordinape ✅ Ready (Inspect) Visit Preview Nov 8, 2022 at 7:45PM (UTC)

@levity
Copy link
Contributor

levity commented Nov 6, 2022

@ivyquinzel did you get a chance to vet this UX for toggling between markdown and markdown preview?

@levity
Copy link
Contributor

levity commented Nov 6, 2022

@sshmm i don't understand why you're running sanitize-html first, and then rendering that in a markdown preview. Isn't it already html?

Also, I think it would be better to store markdown in the db, not html. It's more usable in other contexts then.

@sshmm
Copy link
Contributor Author

sshmm commented Nov 6, 2022

@sshmm i don't understand why you're running sanitize-html first, and then rendering that in a markdown preview. Isn't it already html?

To remove scripts and other unwanted malicious entries by the user

@levity
Copy link
Contributor

levity commented Nov 6, 2022 via email

@levity
Copy link
Contributor

levity commented Nov 6, 2022

Actually, I see that the markdown preview component has a skipHtml option to ignore all html tags. This should be a simpler way of accomplishing the same thing.

Note that the option behaves in a confusing way

@sshmm sshmm requested a review from levity November 6, 2022 13:06
@sshmm
Copy link
Contributor Author

sshmm commented Nov 6, 2022

Actually, I see that the markdown preview component has a skipHtml option to ignore all html tags. This should be a simpler way of accomplishing the same thing.

Note that the option behaves in a confusing way

when I tried skipHtml={false} it is working. but it is different from sanitizing. this one keep the html but doesn't render it. unlike sanitizie-html which remove them completly
image
this is the output of sanitize-html, without ignoring all html
image

I think I can use skipHtml in the front end and keep sanitize-html in the backend and use allowedTags: [] with it?
it was topocount idea to but in the back end too so that we only storing sanitized text

@levity
Copy link
Contributor

levity commented Nov 6, 2022 via email

Copy link
Contributor

@levity levity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my initial feedback is:

  • disable dark mode
  • the preview needs some border & padding

and i think we should get a UX review from @ivyquinzel and/or @wingfeatherwave

@levity
Copy link
Contributor

levity commented Nov 7, 2022

i have a feeling it will be better to allow the user to explicitly toggle between editing & previewing (perhaps like in Github) rather than doing it automatically on focus/blur

@sshmm
Copy link
Contributor Author

sshmm commented Nov 7, 2022

i have a feeling it will be better to allow the user to explicitly toggle between editing & previewing (perhaps like in Github) rather than doing it automatically on focus/blur

I agree with you we should get insight from design team on how to proceed in this @ivyquinzel and @wingfeatherwave

levity
levity previously approved these changes Nov 8, 2022
Copy link
Contributor

@levity levity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Let's wait for approval of the design before merging.

@sshmm sshmm deleted the Add_markdown_support_to_epoch_statements branch November 8, 2022 19:57
@levity
Copy link
Contributor

levity commented Nov 9, 2022

this shouldn't have been merged, because tests are failing

@levity
Copy link
Contributor

levity commented Nov 9, 2022

fixed in 769849b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add markdown support to epoch statements
3 participants