views:

68

answers:

0

I would like to implement a Pseudo-Clipboard in a broswer-based application.

This is the cycle.

The user can select or manipulate an 'object' which is a collection of graphical artefacts displayed on a screen.

When they [CTRL][C] I want to be able to persist a representation of those artefacts to some persistent store such that when they [CTRL][V] the applicatation can unpack the represntation and then round-trip an Ajax API call to the server such that the collection of artefacts is pasted in the new location which can be:

  • on the original page
  • on another page on the same site
  • on a page on another instance or our site software (pushing the boat out here, not sure this will ever be possible)

We also need to use the 'real' clipboard to copy and paste out to other applications.

I think there are four possible places I can persist this stuff:

  • if I was writing a desktop Windows app I would load multiple formats to the clipboard including a custom binary format - but I don't think this will work in a browser - I think I get one format and one format only
  • I can stick the representation in a cookie and then retrieve it when I paste - not sure how to wangle this in javascript
  • I can use some sort of local storage mechanism (ie Google Gears) but this gives me permissions and cross-browser issues
  • I can round trip the representation to the server using an Ajax call - maybe pop an entry onto a server-side clipboard stack and share that any pages I view in my logged on session

Any suggestions, criticisms, examples and particular security subtleties much welcome.