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
672 B
Vue
Raw Normal View History

2021-02-01 12:03:30 -08:00
<script>
import spelling from "../plugins/spelling";
2021-04-12 04:57:18 -07:00
const escapeChars = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;'
};
2021-02-01 12:03:30 -08:00
export default {
mixins: [ spelling ],
props: {
text: { required: true },
2021-04-12 04:57:18 -07:00
escape: { type: Boolean }
2021-02-01 12:03:30 -08:00
},
render(h) {
2021-04-12 04:57:18 -07:00
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) }});
2021-02-01 12:03:30 -08:00
},
}
</script>