<template>
    <div>
        <textarea :name="name">{{value}}</textarea>
    </div>
</template>
<script>
    export default {
        props: ['name', 'value'], watch: {
            value(val) {
                this.$emit('update:value', val)
            },
        },
        mounted: function () {
            var vm = this;
            var editor = KindEditor.create('textarea[name="' + this.name + '"]', {
                width: '100%',
                allowImageUpload: true,
                uploadJson: vm.uploadUrl,
                formatUploadUrl: false,
                afterChange: function () {
                    vm.$emit('update:value', this.html());
                }
            });
        },
        computed: {
            src: function () {
                return this.value || '/images/empty.svg';
            }
        }
    };</script>
