Get Value Of Text/HTML Slection BEFORE KeyDown Event In Javascript

156 Views Asked by At

I'm using Froala editor as a WYSIWYG on my app. I am not happy with the way the way it interacts with links and their support said it's simply using ContentEditable for the interaction. If there is a link in the WYSIWYG and I highlight the text and start typing it removes the link instead of changing the text in the link.

So I want to manually manipulate how the link is handled. I can track the KeyDown event just fine, but the problem is once the KeyDown even is fired I've already lost the HTML I was highlighting so I can't do anything with it. My question is there any way to get the value of the highlighted text BEFORE the keydown event is executed?

My Desired Flow:

on.KeyDown check the highlighted text. If Highlighted text contains <a> insert key into the <a>.

0

There are 0 best solutions below