[Vuejs]-Select text inside a paragraph tag

0👍

Thanks to Leeish, here is what I’ve done. It’s a slightly duplicate question apparently, but the answer here might help anyway.

The HTML stay the same, with @mouseup.
On methods I wrote (as quick and dirty example):

mouseup(ev){
      console.log('onselect',ev);
      var gs = window.getSelection();
      var data = gs.baseNode.data;
      var data2 = data.substr(gs.anchorOffset+gs.toString().length,data.length);
      var data1 = data.substr(0,gs.anchorOffset) + gs.toString();     
      console.log(data1);
      console.log(data2);
    },

Leave a comment