Search code examples
javascriptjquerycsstinymce

Disable copy text from tinymce textarea


is there a way to stop copy text from tinymce text area ? i did my try by following code it disable copy from simple text area but i want this restriction on tinymce text area , i am not talking about buttons i am talking about text written in text area

<textarea id="mytinymcetextarea" class="noselect">Not copy able</textarea>

tinymce.init({
 selector: "#mytextarea"
});


$('#mytinymcetextarea').bind('copy',function(e) {
e.preventDefault(); return false; 
});

i also did try by css

.noselect {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
   -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
        user-select: none; /* Non-prefixed version, currently
                              supported by Chrome and Opera */
}

if it is not possible is there anyother text editor which allow to disable copy text.


Solution

  • You could try to intercept the copy event and disable its default behavior:

    document.addEventListener('copy', function(e){
      e.preventDefault(); // default behaviour is to copy selected text
    });
    

    There's no guarantee this will work on all browsers though.

    In addition to this, you could remove the context menu (see: Remove the Context Menu in TinyMCE), and you can also remove the "copy" option from the "Edit" menu in TinyMCE (see: http://codeasp.net/blogs/microsoft-net/204/tinymce-how-to-remove-cut-copy-and-paste-items-in-edit-menu).