I can only get the cursor position of input and textarea elements, but how do I do this with div elements that contain contenteditable = "true"?
getCursor() { const text = this.$refs.test; const value = text.selectionStart; console.log(value); // result is undefined }
<div ref="test" contenteditable="true" :v-html="inputIntegrationHMTL" @input="getCursor($event)" > </div>
Like this?
getCursor(event) { console.log(event); // you can read pos here }
<div ref="test" contenteditable="true" :v-html="inputIntegrationHMTL" @mouseover="getCursor($event)" > </div>
1.4m articles
1.4m replys
5 comments
56.9k users