suyati / line-control

A Light Weight HTML5 Text Editor designed as a JQuery Plugin
Other
124 stars 90 forks source link

How to "Paste as Plain Text" #114

Closed rahulmahadik closed 4 years ago

rahulmahadik commented 4 years ago

How i can to paste the content as a plain text.

rahulmahadik commented 4 years ago

Fixed my adding below code:

$(document).ready(function () {
        document.querySelector("div.Editor-editor[contenteditable]").addEventListener("paste", function (e) {
            e.preventDefault();
            var text = e.clipboardData.getData("text/plain");
            document.execCommand("insertHTML", false, text);
        });
    })