Google-drive – What’s the format of the text that is copied from Google Docs in the clipboard

formattinggoogle-appsgoogle-drive

When I copy text from Google Docs and paste it in the OSX Text Edit application, format and links are preserved. If I copy it into a simple text app, the format is not preserved, but the text is pasted perfectly, as expected.

I assume there is some standard format in which the contents are copied in the clipboard, but what is it?

Best Answer

Basically, Google Docs writes several representations of the data to the pasteboard (that's what it is called in OS X). Then whatever app you paste into reads an appropriate representation of the data from the pasteboard.

From the Pasteboard Programming Guide:

Pasteboard operations are often carried out between two different applications. Neither application has knowledge about the other and the kinds of data each can handle. To maximize the potential for sharing, a pasteboard can hold multiple representations of the same pasteboard item. [...] An item that is added to a pasteboard specifies what representations it is able to provide.

A pasteboard reader must find the data type that best suits its capabilities (if any). Typically, this means selecting the richest type available. [...] a rich text editor might provide RTFD, RTF, and NSString representations of copied data. An application that supports rich text but without images should retrieve the RTF representation; an application that only supports plain text should retrieve the NSString object, whereas an image-editing application might not be able to use the text at all.

The clipboard in Windows works basically the same way.