Labs/Jetpack/JEP/10: Difference between revisions

From MozillaWiki
< Labs‎ | Jetpack‎ | JEP
Jump to navigation Jump to search
Line 34: Line 34:
var words = "The quick brown fox jumped over the lazy dog.";
var words = "The quick brown fox jumped over the lazy dog.";
jetpack.os.clipboard.set( words );
jetpack.os.clipboard.set( words );


var html = "<div>Hello <i>there!</i></div>";
var html = "<div>Hello <i>there!</i></div>";

Revision as of 01:39, 27 May 2009

Draft-template-image.png THIS PAGE IS A WORKING DRAFT Pencil-emoji U270F-gray.png
The page may be difficult to navigate, and some information on its subject might be incomplete and/or evolving rapidly.
If you have any questions or ideas, please add them as a new topic on the discussion page.

JEP 10 - Clipboard Support

  • Author: Aza Raskin <aza at mozilla dot com>
  • Champion: Aza Raskin <aza at mozilla dot com>
  • Status: Draft
  • Type: API Track
  • Created: 26 May 2009

Introduction and Rationale

This JEP describes OS clipboard access to the Jetpack API.

A number of Jetpacks have already implemented their own versions of clipboard access. It makes sense to unify the API and allow for a clean way for Jetpacks to get and set the clipboard in a variety of formats.

As part of this proposal is adding a jetpack.os namespace.

Proposal

Clipboard access will live at jetpack.os.clipboard. The jetpack.os will provide access to anything that relates to the OS (file access, OS info, etc.)

Setting the clipboard

jetpack.os.clipboard.set( data, [dataType] )

The data paramater can be anything, a string, a unicode string, a number, an image, and HTML fragment, etc. that you want to place in the system clipboard.

The optional dataType let's Jetpack know what kind of data is being passed in, in mime-type format. For example, a unicode string would take "text/unicode", HTML would be "text/html", and an PNG would be "image/png". If dataType isn't passed in, Jetpack makes it's best guess.

An example of setting the clipboard in action is as follows:

var words = "The quick brown fox jumped over the lazy dog.";
jetpack.os.clipboard.set( words );

var html = "<div>Hello <i>there!</i></div>";
jetpack.os.clipboard.set( html, "text/html" );

Getting the clipboard

var value = jetpack.os.clipboard.get()