Skip to content

Commit

Permalink
(Proposal) simple solution for #1319 (WIP, see desc)
Browse files Browse the repository at this point in the history
This solution must be properly tested. Also, the `transformLinkUri` key must be added to the admin-application.
  • Loading branch information
Hallbergs committed Apr 25, 2023
1 parent 8ccf592 commit d31860c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions new-client/src/components/FeatureInfo/FeaturePropsParsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default class FeaturePropsParsing {

// Default to true to ensure backwards compatibility with old configs that predominately use HTML
this.allowDangerousHtml = this.options.allowDangerousHtml ?? true;
// Do we want the markdown-renderer to transform the provided uri's or not? Defaults to true to make sure un-safe uri's are not passed by mistake.
// Disabling the transformer could be used to allow for links to desktop applications, for example app://open.
this.transformLinkUri = this.options.transformLinkUri ?? true;

// Here we define the components used by ReactMarkdown, see https://github.com/remarkjs/react-markdown#appendix-b-components
// Note that we import customComponentsForReactMarkdown from our shared library, spread those
Expand Down Expand Up @@ -423,6 +426,7 @@ export default class FeaturePropsParsing {
// will make use of the results in this.resolvedPromises, so that's why we had to wait.
return (
<ReactMarkdown
transformLinkUri={this.transformLinkUri ? undefined : (x) => x} // If transformLinksUri is set to false, we pass a function that simply returns the uri as-is.
remarkPlugins={[gfm]} // GitHub Formatted Markdown adds support for Tables in MD
rehypePlugins={rehypePlugins} // Needed to parse HTML, activated in admin
components={this.components} // Custom renderers for components, see definition in this.components
Expand Down

0 comments on commit d31860c

Please sign in to comment.