Skip to content

Commit dc6a57e

Browse files
authored
Merge pull request #2034 from adrianoesch/patch-1
New dcc.Markdown prop 'link_target'
2 parents 85b955d + 611f620 commit dc6a57e

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1616

1717
- [#1956](https://github.com/plotly/dash/pull/1956) Add TypeScript components generation.
1818

19+
- [#2034](https://github.com/plotly/dash/pull/2034) Add `link_target` prop to dcc.Markdown component. Closes [#1827](https://github.com/plotly/dash/issues/1827)
20+
1921
### Fixed
2022

2123
- [#2029](https://github.com/plotly/dash/pull/2029) Restrict the number of props listed explicitly in generated component constructors - default is 250. This prevents exceeding the Python 3.6 limit of 255 arguments. The omitted props are still in the docstring and can still be provided the same as before, they just won't appear in the signature so autocompletion may be affected.

Diff for: components/dash-core-components/src/components/Markdown.react.js

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ DashMarkdown.propTypes = {
5353
*/
5454
dangerously_allow_html: PropTypes.bool,
5555

56+
/**
57+
* A string for the target attribute to use on links (such as "_blank")
58+
*/
59+
link_target: PropTypes.string,
60+
5661
/**
5762
* A markdown string (or array of strings) that adhreres to the CommonMark spec
5863
*/

Diff for: components/dash-core-components/src/fragments/Markdown.react.js

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default class DashMarkdown extends Component {
8787
highlight_config,
8888
loading_state,
8989
dangerously_allow_html,
90+
link_target,
9091
mathjax,
9192
children,
9293
dedent,
@@ -134,6 +135,7 @@ export default class DashMarkdown extends Component {
134135
<Markdown
135136
source={displayText}
136137
escapeHtml={!dangerously_allow_html}
138+
linkTarget={link_target}
137139
plugins={mathjax ? [RemarkMath] : []}
138140
renderers={{
139141
math: props => (

Diff for: components/dash-core-components/tests/integration/markdown/test_markdown.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from dash import Dash, dcc, html, Input, Output
3+
from dash.testing.wait import until
34

45

56
def test_mkdw001_img(dash_dcc):
@@ -374,3 +375,16 @@ def test_mkdw008_mathjax_visual(dash_dcc):
374375
dash_dcc.percy_snapshot("mkdw008 - markdown and graph with/without mathjax")
375376

376377
assert dash_dcc.get_logs() == []
378+
379+
380+
def test_mkdw009_target_blank_links(dash_dcc):
381+
382+
app = Dash(__name__)
383+
384+
app.layout = dcc.Markdown("[link](https://duckduckgo.com)", link_target="_blank")
385+
386+
dash_dcc.start_server(app)
387+
388+
dash_dcc.find_element("a").click()
389+
390+
until(lambda: len(dash_dcc.driver.window_handles) == 2, timeout=1)

0 commit comments

Comments
 (0)