SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 9b0cd92f authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Display message html, sanitized

parent 1c593b6a
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
"sass": "^1.23.7", "sass": "^1.23.7",
"schema-utils": "^2.5.0", "schema-utils": "^2.5.0",
"sugarss": "^2.0.0", "sugarss": "^2.0.0",
"vue": "^2.6.10" "vue": "^2.6.10",
"vue-sanitize": "^0.2.0"
} }
} }
<template> <template>
<div> <div>
{{ message.data["stripped-html"] }} <h3>Message content:</h3>
<span v-html="sanitized_html"></span>
</div> </div>
</template> </template>
...@@ -11,7 +12,12 @@ ...@@ -11,7 +12,12 @@
message: { message: {
type: Object, type: Object,
required: true required: true
},
},
computed: {
sanitized_html() {
return this.$sanitize(this.message.data["stripped-html"])
} }
} },
} }
</script> </script>
...@@ -7,8 +7,23 @@ Vue.use(BootstrapVue); ...@@ -7,8 +7,23 @@ Vue.use(BootstrapVue);
import 'bootstrap-vue/dist/bootstrap-vue.css'; import 'bootstrap-vue/dist/bootstrap-vue.css';
import VueSanitize from "vue-sanitize";
const sanitizationOptions = {
allowedTags: [ // same as in markup.constants.py
'a', 'abbr', 'acronym', 'b', 'blockquote', 'br', 'code', 'em',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'li', 'ol',
'p', 'pre', 'strong', 'table', 'td', 'th', 'tr', 'ul'
],
allowedAttributes: {
'a': [ 'href' ]
}
};
Vue.use(VueSanitize, sanitizationOptions);
import MessageHeaderList from './components/MessageHeaderList.vue' import MessageHeaderList from './components/MessageHeaderList.vue'
new Vue({ new Vue({
render: h => h(MessageHeaderList), render: h => h(MessageHeaderList),
}).$mount('#message-header-list'); }).$mount('#message-header-list');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment