Alex Rivera | Logout

How to copy-paste from Google Docs with TinyMCE?

Asked 2012-03-29T23:44:06.300
9

My company needs to support the following workflow:

  • There's rich content getting created in Google Docs (with simple formatting - bold/italic, as well as hyperlinks).
  • That content is then pasted into an internal CMS that uses TinyMCE.

Problem: All formatting gets lost when pasting stuff in.

Already tried the "Paste from Word" plugin and it doesn't work.

Update: I narrowed the problem down to Google Chrome. Firefox works just fine. I also used the paste_pre_processing() callbacks — the data gets corrupted before getting in there.

Edit
Report

1 Answer

2

Your problem is a somewhat complex issue.

First you need to make sure that TinyMCE does not remove tags and tag-attributes that it recognises as invalid (have a closer look at the TinyMCE configuration options valid_elements and valid_children).

Second you will have to implement an own handling of the paste process.

There are three way to do this. The most time consuming option is to write an own custom paste plugin and replace the given one. The other options are ways to configure the paste plugins and define own functions to interact with and change the pasted content.

The settings paste_pre_processing and paste_post_processing are the way to go here.

answered 2012-03-30T09:15:16.817

Your Answer