As a functional component of the stray subsystem, the clipboard service provides the ability to manage the system clipboard and supports the system copy and paste functions. The system clipboard supports package text, hypertext, URIs and other content operations.
The clipboard service provides functions that support application developers to use clipboard-related services conveniently and efficiently. Its main components include clipboard management client and clipboard service. The clipboard management client is responsible for clipboard interface management, providing clipboard northbound JS API to applications; creating clipboard data on the application framework side, requesting clipboard SA to perform clipboard creation, deletion, query, text conversion, configuration, etc. The clipboard service is responsible for clipboard event management, manages the life cycle of clipboard SA (startup, destruction, multi-user, etc.); executes application requests, notifies clipboard data management, and returns the results to the clipboard management client.
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteData object of type MIMETYPE_TEXT_HTML for HTML type data</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p3335145451011"><aname="p3335145451011"></a><aname="p3335145451011"></a>Create a PasteData object of type MIMETYPE_TEXT_WANT for data of type want</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteData object of type MIMETYPE_TEXT_PLAIN for plain text data</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteData object of type MIMETYPE_TEXT_URI for data of type URI</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteDataRecord object of type RecordMIMETYPE_TEXT_HTML for hypertext type data</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteDataRecord object of type MIMETYPE_TEXT_WANT for data of type want</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteDataRecord object of type MIMETYPE_TEXT_PLAIN for plain text data</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Create a PasteDataRecord object of type MIMETYPE_TEXT_URI for data of type URI</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Get system clipboard</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Callback called when the open pasteboard content changes</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p3335145451011"><aname="p3335145451011"></a><aname="p3335145451011"></a>Callback called when the content of the pasteboard is closed</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Get system clipboard data object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Get system clipboard data object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Check if there is content in the pasteboard</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Check if there is content in the pasteboard</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Write PasteData to the pasteboard</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Write PasteData to the pasteboard</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Add the HTML text record to the PasteData object and update the MIME type to PasteData#MIMETYPE_TEXT_HTML in the DataProperty.</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p3335145451011"><aname="p3335145451011"></a><aname="p3335145451011"></a>Add want record to PasteData object and update MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Add PasteRecord to paste data object and update MIME type in data attribute</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Add plain text records to PasteData object and update MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Add URI record to PasteData object and update MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>MIME type of everything on the pasteboard</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>HTML text of the main record in the PasteData object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>The want of the main record in the PasteData object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>The MIME type of the main record in the PasteData object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>URI of the main record in the PasteData object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Get the properties of the clipboard data object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>records based on the specified index</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Number of records in PasteData object</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Checks if data of the specified MIME type exists in the DataProperty</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Delete records based on specified index</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Replace the specified record with a new record</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Convert PasteData to text content</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.2.3.1.2 "><pid="p3335145451011"><aname="p3335145451011"></a><aname="p3335145451011"></a>Convert PasteData to text content</p>
<tdclass="cellrowborder"valign="top"width="40%"headers="mcps1.2.3.1.3 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Distinct MIME types for all records in PasteData</p>
<tdclass="cellrowborder"valign="top"width="40%"headers="mcps1.2.3.1.3 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Timestamp indicating when the data was written to the system clipboard.</p>
<tdclass="cellrowborder"valign="top"width="40%"headers="mcps1.2.3.1.3 "><pid="p18761104812149"><aname="p18761104812149"></a><aname="p18761104812149"></a>Check if PasteData is set for local access only.</p>
</td>
</tr>
</tbody>
</table>
### Instructions for use
Clipboard module usage example:
```
// import module
import pasteboard from '@ohos.pasteboard'
//text copy
console.log('Get SystemPasteboard')
var systemPasteboard = pasteboard.getSystemPasteboard()
systemPasteboard.clear()
var textData = 'Hello World!'
console.log('createPlainTextData = ' + textData)
var pasteData = pasteboard.createPlainTextData(textData)
console.log('Writes PasteData to the pasteboard')
systemPasteboard.setPasteData(pasteData)
console.log('Checks there is content in the pasteboard')