<script lang="ts">
import spelling from '../plugins/spelling.ts';
import { escapeHtml } from '../src/helpers.ts';
import { safeInlineMarkdown } from '../src/simpleMarkdown.js';

export default spelling.extend({
    props: {
        text: { default: '', type: String },
        escape: { type: Boolean },
        markdown: { type: Boolean },
    },
    render(h) {
        let text = this.text;
        text = text.replace('<script', '');
        if (this.escape) {
            text = escapeHtml(text);
        }
        if (this.markdown) {
            text = safeInlineMarkdown(text);
        }

        return h('span', { domProps: { innerHTML: this.handleSpelling(text) } });
    },
});
</script>
