From 10e08138cded0925cc8cd16c315702cdaef3364b Mon Sep 17 00:00:00 2001 From: Adrian Oesch <4437435+adrianoesch@users.noreply.github.com> Date: Tue, 3 May 2022 11:04:26 +0200 Subject: [PATCH 1/6] map linkTarget to link_target --- components/dash-core-components/src/fragments/Markdown.react.js | 2 ++ 1 file changed, 2 insertions(+) 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 { ( From 1a2361027467ff455af222be30e95f95d60b3181 Mon Sep 17 00:00:00 2001 From: Adrian Oesch <4437435+adrianoesch@users.noreply.github.com> Date: Tue, 3 May 2022 11:13:29 +0200 Subject: [PATCH 2/6] add link_target prop --- .../dash-core-components/src/components/Markdown.react.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/dash-core-components/src/components/Markdown.react.js b/components/dash-core-components/src/components/Markdown.react.js index 9f98405158..e8d93eadfa 100644 --- a/components/dash-core-components/src/components/Markdown.react.js +++ b/components/dash-core-components/src/components/Markdown.react.js @@ -52,6 +52,12 @@ DashMarkdown.propTypes = { * (https://en.wikipedia.org/wiki/Cross-site_scripting) attack. */ 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 From 2e436eb3bb492c1e081621090c79128288f4f631 Mon Sep 17 00:00:00 2001 From: Adrian Oesch <4437435+adrianoesch@users.noreply.github.com> Date: Tue, 3 May 2022 11:13:59 +0200 Subject: [PATCH 3/6] fix extra line --- components/dash-core-components/src/components/Markdown.react.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/dash-core-components/src/components/Markdown.react.js b/components/dash-core-components/src/components/Markdown.react.js index e8d93eadfa..194550750c 100644 --- a/components/dash-core-components/src/components/Markdown.react.js +++ b/components/dash-core-components/src/components/Markdown.react.js @@ -53,7 +53,6 @@ DashMarkdown.propTypes = { */ dangerously_allow_html: PropTypes.bool, - /** * A string for the target attribute to use on links (such as "_blank") */ From ca36fff66a683e91b3576ad5f809af5fb5bb2fb3 Mon Sep 17 00:00:00 2001 From: adrianoesch <4437435+adrianoesch@users.noreply.github.com> Date: Tue, 3 May 2022 14:07:47 +0200 Subject: [PATCH 4/6] add test --- .../src/components/Markdown.react.js | 2 +- .../tests/integration/markdown/test_markdown.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/dash-core-components/src/components/Markdown.react.js b/components/dash-core-components/src/components/Markdown.react.js index 194550750c..ab99728c2d 100644 --- a/components/dash-core-components/src/components/Markdown.react.js +++ b/components/dash-core-components/src/components/Markdown.react.js @@ -52,7 +52,7 @@ DashMarkdown.propTypes = { * (https://en.wikipedia.org/wiki/Cross-site_scripting) attack. */ dangerously_allow_html: PropTypes.bool, - + /** * A string for the target attribute to use on links (such as "_blank") */ 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) From 444df160f16c95759fe08cd51793f8e85a5a0a36 Mon Sep 17 00:00:00 2001 From: Adrian Oesch <4437435+adrianoesch@users.noreply.github.com> Date: Tue, 3 May 2022 15:50:14 +0200 Subject: [PATCH 5/6] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 717e85100a..d797353beb 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. From 611f6206adbb1e97de7d2adb64a86ad81439f909 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Tue, 3 May 2022 15:19:13 -0400 Subject: [PATCH 6/6] noise