c3lf-system-3/web/src/components/inputs/FormatedText.vue
2024-06-23 04:31:28 +02:00

35 lines
No EOL
754 B
Vue

<template>
<div contenteditable @input="onchange">
<span v-html="rawhtml(value)"></span>
</div>
</template>
<script>
export default {
name: 'FormatedText',
props: {
value: {
type: String,
required: true
},
format: {
type: Function,
default: null
}
},
emits: ['input'],
methods: {
rawhtml(value) {
if (typeof this.format === 'function') {
return this.format(value);
} else {
return value;
}
},
onchange(event) {
this.$emit('input', event.target.innerText);
this.value = event.target.innerText;
}
}
};
</script>