<template>
  <div class="text-form">
    <textarea
      :value="text"
      class="text-form__input skillbox-textarea"
      data-cy="text-form-input"
      placeholder="Text erfassen..."
      @input="$emit('text-change-value', $event.target.value, index)"/>
  </div>
</template>

<script>
  export default {
    props: {
      value: {
        type: Object,
        default: null,
        validator(value) {
          return value.hasOwnProperty('text');
        }
      }
  },

    computed: {
      text() {
        return this.value.text ? this.value.text.replace(/<br(\/)?>/, '\n').replace(/(<([^>]+)>)/ig, '') : '';
      }
    }
  };
</script>

<style scoped lang="scss">
  @import "~styles/helpers";

  .text-form {
    &__input {
      width: $modal-input-width;
    }
  }
</style>
