diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d60cf432a..2c7c9745ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). - [#1956](https://github.com/plotly/dash/pull/1956) Add TypeScript components generation. +- [#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) + ### Fixed - [#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 --git a/components/dash-core-components/src/components/Markdown.react.js b/components/dash-core-components/src/components/Markdown.react.js index 9f98405158..ab99728c2d 100644 --- a/components/dash-core-components/src/components/Markdown.react.js +++ b/components/dash-core-components/src/components/Markdown.react.js @@ -53,6 +53,11 @@ DashMarkdown.propTypes = { */ dangerously_allow_html: PropTypes.bool, + /** + * A string for the target attribute to use on links (such as "_blank") + */ + link_target: PropTypes.string, + /** * A markdown string (or array of strings) that adhreres to the CommonMark spec */ diff --git a/components/dash-core-components/src/fragments/Markdown.react.js b/components/dash-core-components/src/fragments/Markdown.react.js index eff440aa1f..dcd3fa8d14 100644 --- a/components/dash-core-components/src/fragments/Markdown.react.js +++ b/components/dash-core-components/src/fragments/Markdown.react.js @@ -87,6 +87,7 @@ export default class DashMarkdown extends Component { highlight_config, loading_state, dangerously_allow_html, + link_target, mathjax, children, dedent, @@ -134,6 +135,7 @@ export default class DashMarkdown extends Component { ( diff --git a/components/dash-core-components/tests/integration/markdown/test_markdown.py b/components/dash-core-components/tests/integration/markdown/test_markdown.py index a0cbf61c2a..bd4443ef55 100644 --- a/components/dash-core-components/tests/integration/markdown/test_markdown.py +++ b/components/dash-core-components/tests/integration/markdown/test_markdown.py @@ -1,5 +1,6 @@ import pytest from dash import Dash, dcc, html, Input, Output +from dash.testing.wait import until def test_mkdw001_img(dash_dcc): @@ -374,3 +375,16 @@ def test_mkdw008_mathjax_visual(dash_dcc): dash_dcc.percy_snapshot("mkdw008 - markdown and graph with/without mathjax") assert dash_dcc.get_logs() == [] + + +def test_mkdw009_target_blank_links(dash_dcc): + + app = Dash(__name__) + + app.layout = dcc.Markdown("[link](https://duckduckgo.com)", link_target="_blank") + + dash_dcc.start_server(app) + + dash_dcc.find_element("a").click() + + until(lambda: len(dash_dcc.driver.window_handles) == 2, timeout=1)