diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15ed5a2f..63cbead0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
- matrix: clone matrices not properly storing their children's values
- widgets
+ - **new** html widget
- frames: allow loading local html files without requiring a web server to serve them
- text: escape html tags characters (`<` & `>`)
- input: added `asYouType` property
diff --git a/package.json b/package.json
index 5276995b..14d4c73f 100644
--- a/package.json
+++ b/package.json
@@ -56,6 +56,7 @@
"nosleep.js": "0.9.0",
"osc": "2.3.1",
"python-shell": "1.0.8",
+ "sanitize-html": "^1.20.1",
"scope-css": "1.2.1",
"screenfull": "4.2.1",
"send": "0.17.1",
diff --git a/src/client/app/widgets/index.js b/src/client/app/widgets/index.js
index b5942b4e..4bb00a72 100644
--- a/src/client/app/widgets/index.js
+++ b/src/client/app/widgets/index.js
@@ -36,6 +36,7 @@ module.exports.widgets = {
text: require('./plots/text'),
image: require('./plots/image'),
svg: require('./plots/svg'),
+ html: require('./plots/html'),
frame: require('./plots/frame'),
// containers
@@ -63,7 +64,7 @@ module.exports.categories = {
'Buttons':['toggle','push','switch', 'dropdown'],
'Pads':['xy','rgb','multixy'],
'Matrices':['matrix', 'keyboard', 'patchbay'],
- 'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text', 'image', 'svg', 'frame'],
+ 'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text', 'image', 'svg', 'html', 'frame'],
'Containers':['panel','strip','modal', 'clone'],
'Switchers':['state', 'switcher','crossfader'],
'Inputs':['input', 'keys', 'script', 'gyroscope', 'file']
diff --git a/src/client/app/widgets/plots/html.js b/src/client/app/widgets/plots/html.js
new file mode 100644
index 00000000..573eda52
--- /dev/null
+++ b/src/client/app/widgets/plots/html.js
@@ -0,0 +1,72 @@
+var Widget = require('../common/widget'),
+ morph = require('nanomorph'),
+ html = require('nanohtml'),
+ sanitizeHtml = require('sanitize-html')
+
+var sanitizeOptions = {
+ allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2']).filter(x=>x!=='iframe')
+}
+
+class Html extends Widget {
+
+ static defaults() {
+
+ return super.defaults({
+
+ _html:'html',
+
+ html: {type: 'string', value: '', help: [
+ 'Allowed HTML tags:',
+ ' h1-6, blockquote, p, a, ul, ol, nl, li,',
+ ' b, i, strong, em, strike, code, hr, br, div,',
+ ' table, thead, img, caption, tbody, tr, th, td, pre'
+ ]},
+ border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'},
+
+ }, ['color', 'target', 'precision', 'bypass'], {})
+
+ }
+
+ constructor(options) {
+
+ super({...options, html: html`
+
+
+ `})
+
+ if (!this.getProp('border')) this.container.classList.add('noborder')
+
+ }
+
+ updateHtml(){
+
+ var newHtml = html``
+
+ newHtml.innerHTML = sanitizeHtml(this.getProp('html'), sanitizeOptions)
+
+ morph(this.widget, newHtml)
+
+ }
+
+ onPropChanged(propName, options, oldPropValue) {
+
+ if (super.onPropChanged(...arguments)) return true
+
+ switch (propName) {
+
+ case 'html':
+ this.updateHtml()
+ return
+
+ }
+
+ }
+
+
+}
+
+Html.dynamicProps = Html.prototype.constructor.dynamicProps.concat(
+ 'html'
+)
+
+module.exports = Html
diff --git a/src/client/app/widgets/plots/svg.js b/src/client/app/widgets/plots/svg.js
index c9301b97..d3dc5463 100644
--- a/src/client/app/widgets/plots/svg.js
+++ b/src/client/app/widgets/plots/svg.js
@@ -15,7 +15,9 @@ class Svg extends Widget {
'Svg xml definition:',
'- will be wrapped in a `< svg />` element',
'- `` commands support a special percent notation (`%x` and `%y`)'
- ]}
+ ]},
+ border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'},
+
}, ['color', 'target', 'precision', 'bypass'], {})
@@ -34,6 +36,8 @@ class Svg extends Widget {
this.on('resize', this.resizeHandleProxy.bind(this), {element: this.widget})
+ if (!this.getProp('border')) this.container.classList.add('noborder')
+
}
updateSvg(){
diff --git a/src/scss/widgets/plots.scss b/src/scss/widgets/plots.scss
index d4216456..a0ec1fb1 100644
--- a/src/scss/widgets/plots.scss
+++ b/src/scss/widgets/plots.scss
@@ -138,7 +138,6 @@
flex: 1 1 100%;
background: var(--color-track);
border:1rem solid var(--color-bg);
- @extend .glass-effect;
svg {
flex: 1 1 100%;
}
@@ -150,12 +149,46 @@
background: transparent;
padding: 0!important;
.svg {
+ background: transparent;
outline:transparent!important;
border:0!important;
box-shadow:none!important;
margin: 0!important;
}
}
+ &:not(.noborder) .svg {
+ @extend .glass-effect;
+ }
+}
+
+.html-container {
+ width:100rem;
+ height:100rem;
+ padding:1rem;
+ .html {
+ display: flex;
+ flex-direction: row;
+ flex: 1 1 100%;
+ background: var(--color-track);
+ border:1rem solid var(--color-bg);
+ }
+ &.noborder {
+ --color-border:transparent;
+ --color-light:transparent;
+ --color-light:transparent;
+ background: transparent;
+ padding: 0!important;
+ .html {
+ background: transparent;
+ outline:transparent!important;
+ border:0!important;
+ box-shadow:none!important;
+ margin: 0!important;
+ }
+ }
+ &:not(.noborder) .html {
+ @extend .glass-effect;
+ }
}
.frame-container {
@@ -213,10 +246,11 @@
.panel:not(.tab) > .plot-container,
.panel:not(.tab) > .image-container,
.panel:not(.tab) > .frame-container,
-.panel:not(.tab) > .svg-container {
+.panel:not(.tab) > .svg-container,
+.panel:not(.tab) > .html-container {
--color-border:transparent;
padding: 0rem;
- .plot, .text, .led, .image, .svg, .frame {
+ .plot, .text, .led, .image, .svg, .html, .frame {
margin: 1rem;
box-shadow: 0 0 0 1rem var(--color-light),
0 0 0 1rem var(--color-fg);