Skip to content

Commit

Permalink
Merge pull request #2034 from adrianoesch/patch-1
Browse files Browse the repository at this point in the history
New dcc.Markdown prop 'link_target'
  • Loading branch information
alexcjohnson authored May 3, 2022
2 parents 85b955d + 611f620 commit dc6a57e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default class DashMarkdown extends Component {
highlight_config,
loading_state,
dangerously_allow_html,
link_target,
mathjax,
children,
dedent,
Expand Down Expand Up @@ -134,6 +135,7 @@ export default class DashMarkdown extends Component {
<Markdown
source={displayText}
escapeHtml={!dangerously_allow_html}
linkTarget={link_target}
plugins={mathjax ? [RemarkMath] : []}
renderers={{
math: props => (
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit dc6a57e

Please sign in to comment.