Floricel
Floricel

Reputation: 801

How can I prevent tinyMCE's paste event?

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.

Upvotes: 3

Views: 3764

Answers (3)

Maifee Ul Asad
Maifee Ul Asad

Reputation: 4579

Here is the solution:

paste_preprocess: function (plugin, args) {
    args.content = ''; // modify or do anything with the clipboard data
},

Do it inside, init

Upvotes: 0

Marcelo Assis
Marcelo Assis

Reputation: 5214

I think it's better to use the paste_preprocess function.

It's a old question, but others may stumble on this problem.

Upvotes: 0

Floricel
Floricel

Reputation: 801

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 = '';
      } 
}

Upvotes: 2

Related Questions