I need to prevent the paste event of tinyMCE if the length of the current content of editor plus the length of the words to be pasted exceed the specified limit. How can I do it? Thank you.
Asked
Active
Viewed 3,439 times
3 Answers
2
I was wrong. I dont need to prevent or disable paste in tinyMCE to do this. I used their paste plugin and modified the content before it is pasted.
function(pl, o) {
...
if(len > limit) {
o.content = '';
}
}

Floricel
- 791
- 2
- 9
- 20
-
+1 that is the proper way to go here (using the tinymce setting paste_preprocess) – Thariama Feb 22 '13 at 10:06
-
If the user has a range of text selected when they paste, isn't this effectively going to delete the text they have highlighted? – Blair Connolly Jun 21 '18 at 15:38
0
I think it's better to use the paste_preprocess function.
It's a old question, but others may stumble on this problem.

Marcelo Assis
- 5,136
- 3
- 33
- 54
0
Here is the solution:
paste_preprocess: function (plugin, args) {
args.content = ''; // modify or do anything with the clipboard data
},
Do it inside, init

Maifee Ul Asad
- 3,992
- 6
- 38
- 86