Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Open
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
34 changes: 34 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ignore JS config files/folders
node_modules/
coverage/
src/
lib/
.babelrc
.builderrc
.eslintrc
.npmignore
.editorconfig
.eslintignore
.prettierrc
.circleci
.github

# demo folder has special meaning in R
# this should hopefully make it still
# allow for the possibility to make R demos
demo/.*\.js
demo/.*\.html
demo/.*\.css

# ignore Python files/folders
setup.py
usage.py
setup.py
requirements.txt
MANIFEST.in
CHANGELOG.md
test/
# CRAN has weird LICENSE requirements
LICENSE.txt
^.*\.Rproj$
^\.Rproj\.user$
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).


## 0.0.3 - 2020-07-27
### Changed
- Add `dash` to `install_requires` for better compatibility with `conda`
### Added
- Added initial release of R package

## 0.0.2 - 2018-12-18
### Changed
Expand Down
13 changes: 13 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: dashDangerouslySetInnerHtml
Title: A dash component for specifying raw HTML
Version: 0.0.3
Description: A dash component for specifying raw HTML
Depends: R (>= 3.0.2)
Imports:
Suggests: dash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to add an example within the package if we want to submit this to CRAN, and if that example requires dashHtmlComponents, we'll have to add it to the Suggests: field here.

License: MIT + file LICENSE
URL: https://github.com/plotly/dash-dangerously-set-inner-html
BugReports: https://github.com/plotly/dash-dangerously-set-inner-html/issues
Encoding: UTF-8
LazyData: true
KeepSource: true
1 change: 1 addition & 0 deletions LICENSE
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AUTO GENERATED FILE - DO NOT EDIT

export(htmlDangerouslySetInnerHTML)
18 changes: 18 additions & 0 deletions R/htmlDangerouslySetInnerHTML.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# AUTO GENERATED FILE - DO NOT EDIT

htmlDangerouslySetInnerHTML <- function(children=NULL) {

props <- list(children=children)
if (length(props) > 0) {
props <- props[!vapply(props, is.null, logical(1))]
}
component <- list(
props = props,
type = 'DangerouslySetInnerHTML',
namespace = 'dash_dangerously_set_inner_html',
propNames = c('children'),
package = 'dashDangerouslySetInnerHtml'
)

structure(component, class = c('dash_component', 'list'))
}
9 changes: 9 additions & 0 deletions R/internal.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.dashDangerouslySetInnerHtml_js_metadata <- function() {
deps_metadata <- list(`dash_dangerously_set_inner_html` = structure(list(name = "dash_dangerously_set_inner_html",
version = "0.0.3", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'bundle.js',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, I'd actually suggest that this package rename its bundle to something more descriptive, as we have with other projects, but it's not essential for this PR.

stylesheet = NULL, head = NULL, attachment = NULL, package = "dashDangerouslySetInnerHtml",
all_files = FALSE), class = "html_dependency"))
return(deps_metadata)
}
47 changes: 47 additions & 0 deletions dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# AUTO GENERATED FILE - DO NOT EDIT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we update the Python artifacts as part of this PR as well? If we're updating both Python and R, I imagine we'll need to make a new release on the 🐍 side also.


from dash.development.base_component import Component, _explicitize_args


class DangerouslySetInnerHTML(Component):
"""A DangerouslySetInnerHTML component.
Render a string of raw, unescaped HTML.
This uses React.js's `dangerouslySetInnerHTML` method.
From React.js's documentation, note that:
> Setting HTML from code is risky because it's easy to
> inadvertently expose your users to a cross-site scripting (XSS)
> (https://en.wikipedia.org/wiki/Cross-site_scripting)
> attack.
So, you can set HTML directly in Dash through React.js, but you have
to type out dangerouslySetInnerHTML to remind yourself that it's dangerous.

In most cases, you are safer using the Dash HTML component classes,
dash-html-components (https://github.com/plotly/dash-html-components).
You can also provide HTML in a sandboxed iframe using the
`dash_html_components.IFrame(srcDoc='raw html here')` component,
see , see https://community.plotly.com/t/rendering-html-similar-to-markdown/6232/2?u=chriddyp

Note that the elements in the HTML block that is generated will can not
be targeted with Dash callbacks.

Keyword arguments:
- children (string; optional): An string of raw, unescaped HTML that will be rendered directly"""
@_explicitize_args
def __init__(self, children=None, **kwargs):
self._prop_names = ['children']
self._type = 'DangerouslySetInnerHTML'
self._namespace = 'dash_dangerously_set_inner_html'
self._valid_wildcard_attributes = []
self.available_properties = ['children']
self.available_wildcard_properties = []

_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
_locals.update(kwargs) # For wildcard attrs
args = {k: _locals[k] for k in _explicit_args if k != 'children'}

for k in []:
if k not in args:
raise TypeError(
'Required argument `' + k + '` was not specified.')
super(DangerouslySetInnerHTML, self).__init__(children=children, **args)
5 changes: 5 additions & 0 deletions dash_dangerously_set_inner_html/_imports_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .DangerouslySetInnerHTML import DangerouslySetInnerHTML

__all__ = [
"DangerouslySetInnerHTML"
]
47 changes: 47 additions & 0 deletions dash_dangerously_set_inner_html/package-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past I've avoided contributing the package-info.json, adding just the changes to package.json instead.

"name": "dash-dangerously-set-inner-html",
"version": "0.0.3",
"description": "A dash component for specifying raw HTML",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/plotly/dash-dangerously-set-inner-html.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/plotly/dash-dangerously-set-inner-html/issues"
},
"homepage": "https://github.com/plotly/dash-dangerously-set-inner-html",
"scripts": {
"copy-lib": "copyfiles -u 1 lib/* dash_dangerously_set_inner_html",
"demo": "builder run demo",
"install-local": "npm run copy-lib && python setup.py install",
"prepublish": "npm test && builder run build-dist && npm run copy-lib",
"publish-all": "npm publish && python setup.py sdist upload",
"publish-pypi": "npm run prepublish && python setup.py sdist upload",
"start": "builder run build-dev",
"test": "",
"test-watch": "builder run test-frontend-watch",
"test-debug": "builder run test-frontend-debug",
"uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y",
"build:py_and_r": "dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json && dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json --r-prefix 'html' --r-suggests 'dash'"
},
"author": "Chris Parmer <chris@plotly.com>",
"dependencies": {
"builder": "3.2.2",
"copyfiles": "^1.2.0",
"dash-components-archetype": "^0.2.11",
"prop-types": "^15.6.2",
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"devDependencies": {
"dash-components-archetype-dev": "^0.2.11",
"enzyme": "^2.8.2",
"react-test-renderer": "^15.5.4"
},
"peerDependencies": {
"react": "^15.6.0 || ^16.0.0",
"react-dom": "^15.6.0 || ^16.0.0"
}
}
1 change: 1 addition & 0 deletions inst/deps/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/htmlDangerouslySetInnerHTML.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
% Auto-generated: do not edit by hand
\name{htmlDangerouslySetInnerHTML}

\alias{htmlDangerouslySetInnerHTML}

\title{DangerouslySetInnerHTML component}

\description{
Render a string of raw, unescaped HTML. This uses React.js's `dangerouslySetInnerHTML` method. From React.js's documentation, note that: > Setting HTML from code is risky because it's easy to > inadvertently expose your users to a cross-site scripting (XSS) > (https://en.wikipedia.org/wiki/Cross-site_scripting) > attack. So, you can set HTML directly in Dash through React.js, but you have to type out dangerouslySetInnerHTML to remind yourself that it's dangerous. In most cases, you are safer using the Dash HTML component classes, dash-html-components (https://github.com/plotly/dash-html-components). You can also provide HTML in a sandboxed iframe using the `dash_html_components.IFrame(srcDoc='raw html here')` component, see , see https://community.plotly.com/t/rendering-html-similar-to-markdown/6232/2?u=chriddyp Note that the elements in the HTML block that is generated will can not be targeted with Dash callbacks.
}

\usage{
htmlDangerouslySetInnerHTML(children=NULL)
}

\arguments{
\item{children}{Character. An string of raw, unescaped HTML that will be rendered directly}
}

\value{named list of JSON elements corresponding to React.js properties and their values}

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"test": "",
"test-watch": "builder run test-frontend-watch",
"test-debug": "builder run test-frontend-debug",
"uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y"
"uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y",
"build:py_and_r": "dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json && dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json --r-prefix 'html' --r-suggests 'dash'"
},
"author": "Chris Parmer <chris@plotly.com>",
"dependencies": {
"builder": "3.2.2",
"copyfiles": "^1.2.0",
Expand Down