This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/Spelling.vue

28 lines
678 B
Vue

<script>
import spelling from "../plugins/spelling";
const escapeChars = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;'
};
export default {
mixins: [ spelling ],
props: {
text: { required: true },
escape: { type: Boolean }
},
render(h) {
let text = this.text || '';
text = text.replace('<script', '');
if (this.escape) {
text = text.replace(/[&<>"]/g, tag => escapeChars[tag] || tag);
}
return h('span', {domProps: { innerHTML: this.handleSpelling(text) }});
},
}
</script>