The W3C (World Wide Web Consortium) has an updated working draft for clipboard APIs and events. The document describes this browser API in more detail and outlines the possibilities and potential issues regarding simple clipboard operations such as copy, cut and paste in Web applications. As this document is a working draft, it is intended to become a W3C recommendation. It has not yet become a Web standard and should be considered a work in progress.
What is the benefit of a browser API?
Why would it be necessary to change the default clipboard operations (cut, copy, paste)?
To answer this question, several use cases are suggested, including:
- Rich content editing — It would be helpful to be able to preserve important information when copying text that contains hyperlinks or other structure.
- Graphics with built-in semantics — By allowing copying for more than just the rendered content, it may be possible to create Web applications that allow the manipulation of rich text or graphic content.
- Mathematical information — With mathematics content, simple copying and pasting of rendered text can lead to the loss of most of the semantics.
How is it possible to achieve this?
It is suggested that by providing Web applications with a way to override the user agent internal logic, it would be possible to enable commands even when it appears that the commands should not be available. The document goes on to describe ways to achieve this with detailed information on events (beforecopy event, beforecut event, beforepaste event), clipboard actions and events, a processing model for event dispatch, clipboard event interfaces, writing contents to the clipboard, integration with other scripts and events, pasting HTML and multipart data, and security and privacy considerations.
Other W3C APIs include Pointer Events, which handles pointer input from devices such as mouse, pen or touch screen; the Vibration API, which controls a device’s vibrator; the Indexed Database API, which provides a database of records holding simple values and hierarchical objects; the Geolocation API specification, which gives Web pages access to scripted geographical location information; and Touch Events, which represents points of contact with a touch-sensitive surface.
Further information on the clipboard API and events, as well as any of the other W3C APIs, is available on the W3C website.