-
-
Notifications
You must be signed in to change notification settings - Fork 144
Issue 250 - Support for rendering links inside dcc.Markdown
as dcc.Link
#711
Conversation
webpack.config.js
Outdated
@@ -58,7 +58,7 @@ module.exports = (env, argv) => { | |||
rules: [ | |||
{ | |||
test: /\.jsx?$/, | |||
exclude: /node_modules/, | |||
exclude: /node_modules\/(?!react-jsx-parser\/)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly not transpiled to ES5 so needs to be re-transpiled.
@@ -85,6 +88,10 @@ export default class DashMarkdown extends Component { | |||
const displayText = | |||
dedent && textProp ? this.dedent(textProp) : textProp; | |||
|
|||
const componentTransforms = { | |||
DccLink: props => <DccLink {...props} />, | |||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we define the list of components we want to support are their name in markdown + props customization as needed.
Very cool syntax. Should we do |
src/fragments/Markdown.react.js
Outdated
@@ -110,6 +117,14 @@ export default class DashMarkdown extends Component { | |||
<Markdown | |||
source={displayText} | |||
escapeHtml={!dangerously_allow_html} | |||
renderers={{ | |||
html: props => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we toss in a danderous HTML / XSS test for future sanity?
I like it. Nice general solution. 💃 |
Does this work?
Also, does this work?
What about this?
|
Also could we do a image test that our CSS is OK? That is, that inline
|
Sorry @sudburyrob I meant to tag @rpkyle |
@chriddyp We're in html land now so this does not work:
But this works:
And this works too
That said, nothing would prevent us from going all in and allowing nested markdowns inside the markdown:
Not advocating this, but... it works... who am I to say nested markdowns shouldn't be a thing? 🤷♂️ |
|
- add link vs. dccLink tests
- additional html tests - formating & black
One difference between using |
Another nice enhancement (down the line) would be to enable end users to specify the properties of their
|
Does this mean that using |
Testing it...
Checking if something can be done about it. With some tweaking (https://github.com/TroyAlford/react-jsx-parser Added a test for the inline case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For dash-docs
this will work fine - we can update reusable_components.Markdown
to automatically convert [title](url)
to <dccLink children="title" href="url" />
or whatever, and add dangerously_allow_html=True
. Given that this implementation is pretty easy (and done), let's put it in 💃(once tests pass again)
If anyone else besides dash-docs
is interested in this, we still may want to explore a syntax like [title](%url)
that should work without dangerously_allow_html
and should allow markdown within the link text without re-wrapping it.
Fixes #250
Adds additional node type for
dcc.Link
(vs.link
) and the general mechanism to extend markdown syntax with any React Component of our choosing. Leaves the existing link syntax untouched.Works as-is, no need to setdangerously_allow_html=True
-- which I'm not sure makes sense? Need to investigate / make sure we're not doing something wrong..Requires
dangerously_allow_html=True
to work correctly.Todo
v1.8
also