Search code examples
javascriptvuejs2ecmascript-5

vuejs contenteditable and backline issue


Hy, I try to make markdown editor for vuejs but I can use backline (\n) in the value of my component ! how in can do this ?

for clean formating of the text like stack or github

https://codepen.io/darkiron/pen/bLgqWN

<template>
  <div>
    <div contenteditable="true" class="editor" @input="send"> {{ value }}
   </div>
  </div>
</template>
<script>
  export default {
    props: ['value'],
    methods:{
      send (event) {
        console.log(this.content)
        if (event !== undefined) {
          console.log(event.target.innerHTML)
          this.$emit('input', event.target.innerHTML)
        }

        this.$emit('input', this.value )

      }
    }
  }
</script>

Thanks for your help !


Solution

  • Finaly I use textarea :

    https://github.com/darkiron/EasyMardownEditor It's more eazy ;)