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 Markdown for banner description and warning #366

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

simbabque
Copy link
Contributor

@simbabque simbabque commented Apr 2, 2024

This PR adds Markdown support for both the banner description and banner warning. I've put a bit of detail into #310 already. Here's a summary.

We use react-markdown, which seems to be the most popular choice in the React ecosystem for rendering markdown. It offers XSS protection and can be extended, should we want it.

We only allow basic formatting in Markdown:

  • paragraphs
  • strong and emphasis,
  • ordered and unordered lists

I've opted not to support links and images. I think images are too disruptive for the flow of the website. I think we should discuss whether we want links to be allowed. It's possible at the moment to put URLs in, but they would just not be turned into a clickable link.

Markup that is not allowed will be removed, leading to images and headings being stripped out completely.

I've also added a tooltip to the banner creation screen that includes a short explanation of what's allowed. This is available in all three languages, with the Spanish provided by a native speaker from Argentina.

I've also fixed a console error I noticed for the banner editing buttons on the banner screen.

The banner london-skyline-830f in the test environment has example data for this to be tried out.

Here's a screen recording of it working on the desktop site.

Screen Recording

Closes #310.

Copy link
Member

@ewoerner ewoerner left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. Looking quite good, but please have a look at the two comments.

src/components/banner-edit-tools/BannerEditTools.tsx Outdated Show resolved Hide resolved
This commit introduces react-markdown and allows a small subset of basic
markdown syntax to be used in banner descriptions and warnings. It also
adds a new tooltip during banner creation that explains which parts of
markdown are allowed.

We explicitly only allow a small number of things. Images and
headings are not allowed, as they could break our page layout.
@simbabque
Copy link
Contributor Author

Thank you @ewoerner. I've updated the PR. Links are allowed now, and the bugfix is in a separate PR #370.

@ewoerner ewoerner merged commit 344cce3 into bannergress:main Apr 7, 2024
1 check passed
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.

Evaluate formatting in description / warning
2 participants