diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..0bb1753 --- /dev/null +++ b/.Rbuildignore @@ -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$ diff --git a/CHANGELOG.md b/CHANGELOG.md index 18d12cf..c6c0891 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..7774f24 --- /dev/null +++ b/DESCRIPTION @@ -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 +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 diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..85de3d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +LICENSE.txt \ No newline at end of file diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..28d0cbf --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,3 @@ +# AUTO GENERATED FILE - DO NOT EDIT + +export(htmlDangerouslySetInnerHTML) diff --git a/R/htmlDangerouslySetInnerHTML.R b/R/htmlDangerouslySetInnerHTML.R new file mode 100644 index 0000000..c9e2fc9 --- /dev/null +++ b/R/htmlDangerouslySetInnerHTML.R @@ -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')) +} diff --git a/R/internal.R b/R/internal.R new file mode 100644 index 0000000..48619b8 --- /dev/null +++ b/R/internal.R @@ -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', +stylesheet = NULL, head = NULL, attachment = NULL, package = "dashDangerouslySetInnerHtml", +all_files = FALSE), class = "html_dependency")) +return(deps_metadata) +} diff --git a/dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py b/dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py new file mode 100644 index 0000000..7bd1ae6 --- /dev/null +++ b/dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py @@ -0,0 +1,47 @@ +# AUTO GENERATED FILE - DO NOT EDIT + +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) diff --git a/dash_dangerously_set_inner_html/_imports_.py b/dash_dangerously_set_inner_html/_imports_.py new file mode 100644 index 0000000..bafd865 --- /dev/null +++ b/dash_dangerously_set_inner_html/_imports_.py @@ -0,0 +1,5 @@ +from .DangerouslySetInnerHTML import DangerouslySetInnerHTML + +__all__ = [ + "DangerouslySetInnerHTML" +] \ No newline at end of file diff --git a/dash_dangerously_set_inner_html/package-info.json b/dash_dangerously_set_inner_html/package-info.json new file mode 100644 index 0000000..5471150 --- /dev/null +++ b/dash_dangerously_set_inner_html/package-info.json @@ -0,0 +1,47 @@ +{ + "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 ", + "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" + } +} diff --git a/inst/deps/bundle.js b/inst/deps/bundle.js new file mode 100644 index 0000000..a649d21 --- /dev/null +++ b/inst/deps/bundle.js @@ -0,0 +1 @@ +this.dash_dangerously_set_inner_html=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.DangerouslySetInnerHTML=void 0;var o=r(1),u=n(o);t.DangerouslySetInnerHTML=u.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var t={__html:e.children};return s.default.createElement("div",{dangerouslySetInnerHTML:t})}Object.defineProperty(t,"__esModule",{value:!0});var u=r(5),s=n(u),a=r(3),i=n(a);o.propTypes={children:i.default.string},t.default=o},function(e,t,r){"use strict";function n(){}var o=r(4);e.exports=function(){function e(e,t,r,n,u,s){if(s!==o){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=n,r.PropTypes=r,r}},function(e,t,r){e.exports=r(2)()},function(e,t){"use strict";var r="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=r},function(e,t){!function(){e.exports=this.React}()}]); \ No newline at end of file diff --git a/man/htmlDangerouslySetInnerHTML.Rd b/man/htmlDangerouslySetInnerHTML.Rd new file mode 100644 index 0000000..37a9ba7 --- /dev/null +++ b/man/htmlDangerouslySetInnerHTML.Rd @@ -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} + diff --git a/package.json b/package.json index 57c50bf..5471150 100644 --- a/package.json +++ b/package.json @@ -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 ", "dependencies": { "builder": "3.2.2", "copyfiles": "^1.2.0",