Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dcc.Markdown prop 'link_target' #2034

Merged
merged 8 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)