html property: allow "href" attribute on "a" elements
This commit is contained in:
parent
3a1e458d8c
commit
cd7a29c51e
3 changed files with 21 additions and 18 deletions
|
|
@ -1042,13 +1042,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
updateHtml(){
|
||||
|
||||
var extraHtml = this.getProp('html') !== '' ? sanitizeHtml(this.getProp('html'), {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2']).filter(x=>x!=='iframe'),
|
||||
allowedAttributes: {
|
||||
'*': [ 'title', 'class', 'style', 'type'],
|
||||
'img': [ 'src' , 'title', 'class', 'style', 'width', 'height']
|
||||
}
|
||||
}) : null
|
||||
var extraHtml = this.getProp('html') !== '' ? sanitizeHtml(this.getProp('html'), Widget.sanitizeHtmlOptions) : null
|
||||
|
||||
if (this.extraHtml) {
|
||||
if (!extraHtml) {
|
||||
|
|
@ -1111,6 +1105,18 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
Widget.sanitizeHtmlOptions = {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2']).filter(x=>x!=='iframe'),
|
||||
allowedAttributes: {
|
||||
'*': [ 'title', 'class', 'style'],
|
||||
'img': [ 'src' , 'title', 'class', 'style', 'width', 'height'],
|
||||
'a': ['href', 'target']
|
||||
},
|
||||
transformTags: {
|
||||
'a': sanitizeHtml.simpleTransform('a', {target: '_blank'})
|
||||
}
|
||||
}
|
||||
|
||||
Widget.parsersContexts = {}
|
||||
|
||||
Widget.cssVariables = [
|
||||
|
|
|
|||
|
|
@ -4,14 +4,6 @@ var Widget = require('../common/widget'),
|
|||
sanitizeHtml = require('sanitize-html'),
|
||||
StaticProperties = require('../mixins/static_properties')
|
||||
|
||||
var sanitizeOptions = {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2']).filter(x=>x!=='iframe'),
|
||||
allowedAttributes: {
|
||||
'*': [ 'title', 'class', 'style'],
|
||||
'img': [ 'src' , 'title', 'class', 'style', 'width', 'height']
|
||||
}
|
||||
}
|
||||
|
||||
class Html extends StaticProperties(Widget, {bypass: true}) {
|
||||
|
||||
static description() {
|
||||
|
|
@ -43,7 +35,7 @@ class Html extends StaticProperties(Widget, {bypass: true}) {
|
|||
`})
|
||||
|
||||
this.noValueState = true
|
||||
|
||||
|
||||
if (!this.getProp('border')) this.container.classList.add('noborder')
|
||||
this.frame = DOM.get(this.widget, '.frame')[0]
|
||||
|
||||
|
|
@ -57,7 +49,7 @@ class Html extends StaticProperties(Widget, {bypass: true}) {
|
|||
|
||||
var newHtml = this.frame.cloneNode(false)
|
||||
|
||||
newHtml.innerHTML = sanitizeHtml(this.getProp('html'), sanitizeOptions)
|
||||
newHtml.innerHTML = sanitizeHtml(this.getProp('html'), Widget.sanitizeHtmlOptions)
|
||||
|
||||
morph(this.frame, newHtml)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue