TinyMCE paste button only works in Internet Explorer

3.8k Views Asked by At

When I use the paste button in the toolbar of TinyMCE it says "Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead." It works perfectly in IE. Is there a way to make the Paste button useful in Chrome and FF? Perhaps using a custom button that executes a jQuery paste function that works with modern browsers.

editor.addButton('paste', {
  icon: 'paste',
  onclick: function () {
    pastecontent();
  } 
});

function pastecontent(){
   // get clipboard content
}
3

There are 3 best solutions below

2
On BEST ANSWER

As the message from the editor states this is simply a limitation of what you can / cannot do directly via JavaScript in certain browsers. Whether or not you use jQuery you are still using JavaScript so the underlying limitation will exist.

Imagine what you could do if your arbitrary JavaScript could access the clipboard whenever it liked? "Bad people" don't play by the rules so what if (upon loading a web page) they had JavaScript that grabbed everything from the clipboard and sent it to their servers? Over time the browser manufacturers realized that direct access to the clipboard was "bad" ... by having the user type CRTL+C and CRTL+V you are effectively telling the browser you want it to access the clipboard.

0
On

If a tinyMce editor or generally a webpage could get the result of 'paste' then any website would be able to steal your clipboard data (you may have sensitive data copied in your clipboard!). This is the reason that you cannot fire the paste event via javascript.

Regarding this security restriction, native apps which are using an internal web browser are allowed to do it!

0
On

Side note: If you disable contextmenu then the ctrl+v keybind paste will work as usual.