1
votes

I have a tinyMCE editor and I want to build 2 buttons that allow raw/styled copying to clipboard of the text. Raw works perfectly with getContent({ format : 'text' });

the copyRich2Clip function should mimic the browser behavior of keeping the styling when copying the text. With the below function, when I paste to word it just shows the html tags. How can I get the tinyMCE content in a format that can be pasted with the applied styling so that it will look the same in word as in the browser editor instance?

function copyRich2Clip() {
      var copyText = tinyMCE.activeEditor.getContent();
      var dummy = $('<input>').val(copyText).appendTo('body').select()
      document.execCommand("copy");
      dummy.remove()
    }

Thanks

1

1 Answers

1
votes

I managed it with the execCommand, selectAll and copy

tinyMCE.execCommand('selectAll',true,'id_text');
tinyMCE.execCommand('copy',true,'id_text');