Answer the question
In order to leave comments, you need to log in
How to remove html tags on paste in Wysihtml5?
Need to remove html tags when pasting text into form from clipboard.
If you catch the paste event on a simple textarea without using the wysihtml5 plugin, then you can do it like this:
html:
js:<textarea id="textarea"></textarea>
var editor = document.getElementById('textarea');
editor.addEventListener("paste", function(e) {
// отменяем дефолтное поведение
e.preventDefault();
// получаем текст из буфера
var text = e.clipboardData.getData("text/plain");
// вставляем текст в форму
document.execCommand("insertHTML", false, text);
});
var wysi_editor = new wysihtml5.Editor("node-content", {});
wysi_editor.on("paste", function(e) {
console.log(e);
});
console.log(e);
wysi_editor.on("paste", function(e) {
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question