Simulating the paste's event automated scrolling

Viewed 24

I am working with a <div contenteditable></div> element, and I wanted to override the default paste event to remove all sorts of formatting.

document.querySelector("div[contenteditable]").addEventListener("paste", function(event) {
    event.preventDefault();
    document.execCommand("insertText", false, event.clipboardData.getData("text/plain"));
});

It works, but when pasting something, once it overflows the current scrolled area, it is required for the user to scroll down manually.

enter image description here

I've thought about scrolling into the caret's location, but I have no idea how to do this, as it is not a DOM element. What could be the solution to the problem? Any help is appreciated!

0 Answers
Related