1bc03f14fSopenharmony_ci# pasteBoardService
2bc03f14fSopenharmony_ci
3bc03f14fSopenharmony_ci## Introduction
4bc03f14fSopenharmony_ci
5bc03f14fSopenharmony_ci​     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.
6bc03f14fSopenharmony_ci
7bc03f14fSopenharmony_ci**picture 1**  Subsystem Architecture Diagram
8bc03f14fSopenharmony_ci![](figures/subsystem_architecture.png "Subsystem architecture")
9bc03f14fSopenharmony_ci
10bc03f14fSopenharmony_ci​		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.
11bc03f14fSopenharmony_ci
12bc03f14fSopenharmony_ci
13bc03f14fSopenharmony_ci
14bc03f14fSopenharmony_ci## Directory Structure
15bc03f14fSopenharmony_ci
16bc03f14fSopenharmony_ci```
17bc03f14fSopenharmony_ci/foundation/distributeddatamgr/pasteboard
18bc03f14fSopenharmony_ci├── etc         # Configuration files for the processes contained in the component
19bc03f14fSopenharmony_ci├── figures     # Framework diagram
20bc03f14fSopenharmony_ci├── framework   # innerKit interface
21bc03f14fSopenharmony_ci├── interfaces  # The interface code provided by the component externally
22bc03f14fSopenharmony_ci│   └── kits    # Interface provided to the application
23bc03f14fSopenharmony_ci├── profile     # Configuration files for system services contained in the component
24bc03f14fSopenharmony_ci├── services    # clipboard service implementation
25bc03f14fSopenharmony_ci│    └── core   # Core code implementation
26bc03f14fSopenharmony_ci│    └── test   # native test code
27bc03f14fSopenharmony_ci│    └── zidl   # Cross-process communication code implementation
28bc03f14fSopenharmony_ci├── utils       # Tests or services use mocked data
29bc03f14fSopenharmony_ci└──README.md    # Instructions for use
30bc03f14fSopenharmony_ci```
31bc03f14fSopenharmony_ci
32bc03f14fSopenharmony_ci## illustrate
33bc03f14fSopenharmony_ci
34bc03f14fSopenharmony_ci### Interface Description
35bc03f14fSopenharmony_ci
36bc03f14fSopenharmony_ci**list 1**   PasteBoard open main method
37bc03f14fSopenharmony_ci
38bc03f14fSopenharmony_ci<table><thead align="left"><tr id="row143351854201012"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p103351154121010"><a name="p103351154121010"></a><a name="p103351154121010"></a>interface name</p>
39bc03f14fSopenharmony_ci</th>
40bc03f14fSopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>describe</p>
41bc03f14fSopenharmony_ci</th>
42bc03f14fSopenharmony_ci</tr>
43bc03f14fSopenharmony_ci</thead>
44bc03f14fSopenharmony_ci<tbody><tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createHtmlData(htmlText: string): PasteData;</p>
45bc03f14fSopenharmony_ci</td>
46bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteData object of type MIMETYPE_TEXT_HTML for HTML type data</p>
47bc03f14fSopenharmony_ci</td>
48bc03f14fSopenharmony_ci</tr>
49bc03f14fSopenharmony_ci<tr id="row13335054111018"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12832214151418"><a name="p12832214151418"></a><a name="p12832214151418"></a>createWantData(want: Want): PasteData;</p>
50bc03f14fSopenharmony_ci</td>
51bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p3335145451011"><a name="p3335145451011"></a><a name="p3335145451011"></a>Create a PasteData object of type MIMETYPE_TEXT_WANT for data of type want</p>
52bc03f14fSopenharmony_ci</td>
53bc03f14fSopenharmony_ci</tr>
54bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createPlainTextData(text: string): PasteData</p>
55bc03f14fSopenharmony_ci</td>
56bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteData object of type MIMETYPE_TEXT_PLAIN for plain text data</p>
57bc03f14fSopenharmony_ci</td>
58bc03f14fSopenharmony_ci</tr>
59bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createUriData(uri: string): PasteData;</p>
60bc03f14fSopenharmony_ci</td>
61bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteData object of type MIMETYPE_TEXT_URI for data of type URI</p>
62bc03f14fSopenharmony_ci</td>
63bc03f14fSopenharmony_ci</tr>
64bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createHtmlTextRecord(htmlText: string): PasteDataRecord;</p>
65bc03f14fSopenharmony_ci</td>
66bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteDataRecord object of type RecordMIMETYPE_TEXT_HTML for hypertext type data</p>
67bc03f14fSopenharmony_ci</td>
68bc03f14fSopenharmony_ci</tr>
69bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createWantRecord(want: Want): PasteDataRecord;</p>
70bc03f14fSopenharmony_ci</td>
71bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteDataRecord object of type MIMETYPE_TEXT_WANT for data of type want</p>
72bc03f14fSopenharmony_ci</td>
73bc03f14fSopenharmony_ci</tr>
74bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createPlainTextRecord(text: string): PasteDataRecord;</p>
75bc03f14fSopenharmony_ci</td>
76bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteDataRecord object of type MIMETYPE_TEXT_PLAIN for plain text data</p>
77bc03f14fSopenharmony_ci</td>
78bc03f14fSopenharmony_ci</tr>
79bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>createUriRecord(uri: string): PasteDataRecord;</p>
80bc03f14fSopenharmony_ci</td>
81bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Create a PasteDataRecord object of type MIMETYPE_TEXT_URI for data of type URI</p>
82bc03f14fSopenharmony_ci</td>
83bc03f14fSopenharmony_ci</tr>
84bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getSystemPasteboard(): SystemPasteboard</p>
85bc03f14fSopenharmony_ci</td>
86bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Get system clipboard</p>
87bc03f14fSopenharmony_ci</td>
88bc03f14fSopenharmony_ci</tr>
89bc03f14fSopenharmony_ci</tbody>
90bc03f14fSopenharmony_ci</table>
91bc03f14fSopenharmony_ci
92bc03f14fSopenharmony_ci
93bc03f14fSopenharmony_ci
94bc03f14fSopenharmony_ci**list 2**  SystemPasteboard open main method
95bc03f14fSopenharmony_ci
96bc03f14fSopenharmony_ci<table><thead align="left"><tr id="row143351854201012"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p103351154121010"><a name="p103351154121010"></a><a name="p103351154121010"></a>interface name</p>
97bc03f14fSopenharmony_ci</th>
98bc03f14fSopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>describe</p>
99bc03f14fSopenharmony_ci</th>
100bc03f14fSopenharmony_ci</tr>
101bc03f14fSopenharmony_ci</thead>
102bc03f14fSopenharmony_ci<tbody><tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>on(type:'update', callback: () => void): void;</p>
103bc03f14fSopenharmony_ci</td>
104bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Callback called when the open pasteboard content changes</p>
105bc03f14fSopenharmony_ci</td>
106bc03f14fSopenharmony_ci</tr>
107bc03f14fSopenharmony_ci<tr id="row13335054111018"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12832214151418"><a name="p12832214151418"></a><a name="p12832214151418"></a>off(type: 'update', callback?: () => void): void</p>
108bc03f14fSopenharmony_ci</td>
109bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p3335145451011"><a name="p3335145451011"></a><a name="p3335145451011"></a>Callback called when the content of the pasteboard is closed</p>
110bc03f14fSopenharmony_ci</td>
111bc03f14fSopenharmony_ci</tr>
112bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>clear(callback: AsyncCallback<void>): void</p>
113bc03f14fSopenharmony_ci</td>
114bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>clear clipboard</p>
115bc03f14fSopenharmony_ci</td>
116bc03f14fSopenharmony_ci</tr>
117bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>clear(): Promise<void>;</p>
118bc03f14fSopenharmony_ci</td>
119bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>clear clipboard</p>
120bc03f14fSopenharmony_ci</td>
121bc03f14fSopenharmony_ci</tr>
122bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getPasteData(callback: AsyncCallback&lt;PasteData&gt;): void</p>
123bc03f14fSopenharmony_ci</td>
124bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Get system clipboard data object</p>
125bc03f14fSopenharmony_ci</td>
126bc03f14fSopenharmony_ci</tr>
127bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getPasteData():Promise&lt;PasteData&gt;</p>
128bc03f14fSopenharmony_ci</td>
129bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Get system clipboard data object</p>
130bc03f14fSopenharmony_ci</td>
131bc03f14fSopenharmony_ci</tr>
132bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>hasPasteData(callback: AsyncCallback&lt;boolean&gt:void;</p>
133bc03f14fSopenharmony_ci</td>
134bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Check if there is content in the pasteboard</p>
135bc03f14fSopenharmony_ci</td>
136bc03f14fSopenharmony_ci</tr>
137bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>hasPasteData(): Promise&lt;boolean&gt;</p>
138bc03f14fSopenharmony_ci</td>
139bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Check if there is content in the pasteboard</p>
140bc03f14fSopenharmony_ci</td>
141bc03f14fSopenharmony_ci</tr>
142bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>setPasteData(data: PasteData, callback: AsyncCallback&lt;void&gt:void;</p>
143bc03f14fSopenharmony_ci</td>
144bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Write PasteData to the pasteboard</p>
145bc03f14fSopenharmony_ci</td>
146bc03f14fSopenharmony_ci</tr>
147bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>setPasteData(data: PasteData): Promise&lt;void&gt;</p>
148bc03f14fSopenharmony_ci</td>
149bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Write PasteData to the pasteboard</p>
150bc03f14fSopenharmony_ci</td>
151bc03f14fSopenharmony_ci</tr>
152bc03f14fSopenharmony_ci</tbody>
153bc03f14fSopenharmony_ci</table>
154bc03f14fSopenharmony_ci
155bc03f14fSopenharmony_ci
156bc03f14fSopenharmony_ci
157bc03f14fSopenharmony_ci**list 3**  PasteData open main method
158bc03f14fSopenharmony_ci
159bc03f14fSopenharmony_ci<table><thead align="left"><tr id="row143351854201012"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p103351154121010"><a name="p103351154121010"></a><a name="p103351154121010"></a>interface name</p>
160bc03f14fSopenharmony_ci</th>
161bc03f14fSopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>describe</p>
162bc03f14fSopenharmony_ci</th>
163bc03f14fSopenharmony_ci</tr>
164bc03f14fSopenharmony_ci</thead>
165bc03f14fSopenharmony_ci<tbody><tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>addHtmlRecord(htmlText: string): void;</p>
166bc03f14fSopenharmony_ci</td>
167bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="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>
168bc03f14fSopenharmony_ci</td>
169bc03f14fSopenharmony_ci</tr>
170bc03f14fSopenharmony_ci<tr id="row13335054111018"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12832214151418"><a name="p12832214151418"></a><a name="p12832214151418"></a>addWantRecord(want: Want): void;</p>
171bc03f14fSopenharmony_ci</td>
172bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p3335145451011"><a name="p3335145451011"></a><a name="p3335145451011"></a>Add want record to PasteData object and update MIME type to PasteData#MIMETYPE_TEXT_WANT in DataProperty</p>
173bc03f14fSopenharmony_ci</td>
174bc03f14fSopenharmony_ci</tr>
175bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>addRecord(record: PasteDataRecord): void;</p>
176bc03f14fSopenharmony_ci</td>
177bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Add PasteRecord to paste data object and update MIME type in data attribute</p>
178bc03f14fSopenharmony_ci</td>
179bc03f14fSopenharmony_ci</tr>
180bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>addTextRecord(text: string): void;;</p>
181bc03f14fSopenharmony_ci</td>
182bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Add plain text records to PasteData object and update MIME type to PasteData#MIMETYPE_TEXT_PLAIN in DataProperty</p>
183bc03f14fSopenharmony_ci</td>
184bc03f14fSopenharmony_ci</tr>
185bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>addUriRecord(uri: string): void;</p>
186bc03f14fSopenharmony_ci</td>
187bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Add URI record to PasteData object and update MIME type to PasteData#MIMETYPE_TEXT_URI in DataProperty</p>
188bc03f14fSopenharmony_ci</td>
189bc03f14fSopenharmony_ci</tr>
190bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getMimeTypes(): Array&lt;string&gt;</p>
191bc03f14fSopenharmony_ci</td>
192bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>MIME type of everything on the pasteboard</p>
193bc03f14fSopenharmony_ci</td>
194bc03f14fSopenharmony_ci</tr>
195bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getPrimaryHtml(): string;</p>
196bc03f14fSopenharmony_ci</td>
197bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>HTML text of the main record in the PasteData object</p>
198bc03f14fSopenharmony_ci</td>
199bc03f14fSopenharmony_ci</tr>
200bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getPrimaryWant(): Want;</p>
201bc03f14fSopenharmony_ci</td>
202bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>The want of the main record in the PasteData object</p>
203bc03f14fSopenharmony_ci</td>
204bc03f14fSopenharmony_ci</tr>
205bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getPrimaryMimeType(): string;</p>
206bc03f14fSopenharmony_ci</td>
207bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>The MIME type of the main record in the PasteData object</p>
208bc03f14fSopenharmony_ci</td>
209bc03f14fSopenharmony_ci</tr>
210bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getPrimaryUri(): string;</p>
211bc03f14fSopenharmony_ci</td>
212bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>URI of the main record in the PasteData object</p>
213bc03f14fSopenharmony_ci</td>
214bc03f14fSopenharmony_ci</tr>
215bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getProperty(): PasteDataProperty;</p>
216bc03f14fSopenharmony_ci</td>
217bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Get the properties of the clipboard data object</p>
218bc03f14fSopenharmony_ci</td>
219bc03f14fSopenharmony_ci</tr>
220bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getRecordAt(index: number): PasteDataRecord;</p>
221bc03f14fSopenharmony_ci</td>
222bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>records based on the specified index</p>
223bc03f14fSopenharmony_ci</td>
224bc03f14fSopenharmony_ci</tr>
225bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>getRecordCount(): number;</p>
226bc03f14fSopenharmony_ci</td>
227bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Number of records in PasteData object</p>
228bc03f14fSopenharmony_ci</td>
229bc03f14fSopenharmony_ci</tr>
230bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>hasMimeType(mimeType: string): boolean;</p>
231bc03f14fSopenharmony_ci</td>
232bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Checks if data of the specified MIME type exists in the DataProperty</p>
233bc03f14fSopenharmony_ci</td>
234bc03f14fSopenharmony_ci</tr>
235bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>removeRecordAt(index: number): boolean;</p>
236bc03f14fSopenharmony_ci</td>
237bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Delete records based on specified index</p>
238bc03f14fSopenharmony_ci</td>
239bc03f14fSopenharmony_ci</tr>
240bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>replaceRecordAt(index: number, record: PasteDataRecord): boolean;</p>
241bc03f14fSopenharmony_ci</td>
242bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Replace the specified record with a new record</p>
243bc03f14fSopenharmony_ci</td>
244bc03f14fSopenharmony_ci</tr>
245bc03f14fSopenharmony_ci</tbody>
246bc03f14fSopenharmony_ci</table>
247bc03f14fSopenharmony_ci
248bc03f14fSopenharmony_ci
249bc03f14fSopenharmony_ci
250bc03f14fSopenharmony_ci
251bc03f14fSopenharmony_ci
252bc03f14fSopenharmony_ci**list 4**  PasteDataRecord open main method
253bc03f14fSopenharmony_ci
254bc03f14fSopenharmony_ci<table><thead align="left"><tr id="row143351854201012"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p103351154121010"><a name="p103351154121010"></a><a name="p103351154121010"></a>interface name</p>
255bc03f14fSopenharmony_ci</th>
256bc03f14fSopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>describe</p>
257bc03f14fSopenharmony_ci</th>
258bc03f14fSopenharmony_ci</tr>
259bc03f14fSopenharmony_ci</thead>
260bc03f14fSopenharmony_ci<tbody><tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>convertToText(callback: AsyncCallback&lt;string&gt;): void;</p>
261bc03f14fSopenharmony_ci</td>
262bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Convert PasteData to text content</p>
263bc03f14fSopenharmony_ci</td>
264bc03f14fSopenharmony_ci</tr>
265bc03f14fSopenharmony_ci<tr id="row13335054111018"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12832214151418"><a name="p12832214151418"></a><a name="p12832214151418"></a>convertToText():  Promise&lt;void&gt;</p>
266bc03f14fSopenharmony_ci</td>
267bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p3335145451011"><a name="p3335145451011"></a><a name="p3335145451011"></a>Convert PasteData to text content</p>
268bc03f14fSopenharmony_ci</td>
269bc03f14fSopenharmony_ci</tr>
270bc03f14fSopenharmony_ci</tbody>
271bc03f14fSopenharmony_ci</table>
272bc03f14fSopenharmony_ci
273bc03f14fSopenharmony_ci
274bc03f14fSopenharmony_ci
275bc03f14fSopenharmony_ci**list 5**  PasteDataProperty Parameter Description
276bc03f14fSopenharmony_ci
277bc03f14fSopenharmony_ci<table><thead align="left"><tr id="row143351854201012"><th class="cellrowborder" valign="top" width="30%" id="mcps1.2.3.1.1"><p id="p103351154121010"><a name="p103351154121010"></a><a name="p103351154121010"></a>name</p>
278bc03f14fSopenharmony_ci</th>
279bc03f14fSopenharmony_ci<th class="cellrowborder" valign="top" width="30%" id="mcps1.2.3.1.2"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>type</p>
280bc03f14fSopenharmony_ci</th>
281bc03f14fSopenharmony_ci<th class="cellrowborder" valign="top" width="40%" id="mcps1.2.3.1.3"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>illustrate</p>
282bc03f14fSopenharmony_ci</th>
283bc03f14fSopenharmony_ci</tr>
284bc03f14fSopenharmony_ci</thead>
285bc03f14fSopenharmony_ci<tbody><tr id="row204321219393"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>additions{[key:string]}</p>
286bc03f14fSopenharmony_ci</td>
287bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>object</p>
288bc03f14fSopenharmony_ci</td>
289bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="40%" headers="mcps1.2.3.1.3 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Additional property data key-value pair</p>
290bc03f14fSopenharmony_ci</td>
291bc03f14fSopenharmony_ci</tr>
292bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>mimeTypes</p>
293bc03f14fSopenharmony_ci</td>
294bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Array<string></p>
295bc03f14fSopenharmony_ci</td>
296bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="40%" headers="mcps1.2.3.1.3 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Distinct MIME types for all records in PasteData</p>
297bc03f14fSopenharmony_ci</td>
298bc03f14fSopenharmony_ci</tr>
299bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>tag</p>
300bc03f14fSopenharmony_ci</td>
301bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>string</p>
302bc03f14fSopenharmony_ci</td>
303bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="40%" headers="mcps1.2.3.1.3 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>User-defined labels for PasteData objects</p>
304bc03f14fSopenharmony_ci</td>
305bc03f14fSopenharmony_ci</tr>
306bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>timestamp</p>
307bc03f14fSopenharmony_ci</td>
308bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>number</p>
309bc03f14fSopenharmony_ci</td>
310bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="40%" headers="mcps1.2.3.1.3 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Timestamp indicating when the data was written to the system clipboard.</p>
311bc03f14fSopenharmony_ci</td>
312bc03f14fSopenharmony_ci</tr>
313bc03f14fSopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>localOnly</p>
314bc03f14fSopenharmony_ci</td>
315bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a> boolean</p>
316bc03f14fSopenharmony_ci</td>
317bc03f14fSopenharmony_ci<td class="cellrowborder" valign="top" width="40%" headers="mcps1.2.3.1.3 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Check if PasteData is set for local access only.</p>
318bc03f14fSopenharmony_ci</td>
319bc03f14fSopenharmony_ci</tr>
320bc03f14fSopenharmony_ci</tbody>
321bc03f14fSopenharmony_ci</table>
322bc03f14fSopenharmony_ci
323bc03f14fSopenharmony_ci
324bc03f14fSopenharmony_ci### Instructions for use
325bc03f14fSopenharmony_ci
326bc03f14fSopenharmony_ciClipboard module usage example:
327bc03f14fSopenharmony_ci
328bc03f14fSopenharmony_ci```
329bc03f14fSopenharmony_ci// import module
330bc03f14fSopenharmony_ciimport pasteboard from '@ohos.pasteboard'
331bc03f14fSopenharmony_ci//text copy
332bc03f14fSopenharmony_ciconsole.log('Get SystemPasteboard')
333bc03f14fSopenharmony_civar systemPasteboard = pasteboard.getSystemPasteboard()
334bc03f14fSopenharmony_cisystemPasteboard.clear()
335bc03f14fSopenharmony_ci        
336bc03f14fSopenharmony_civar textData = 'Hello World!'
337bc03f14fSopenharmony_ciconsole.log('createPlainTextData = ' + textData)
338bc03f14fSopenharmony_civar pasteData = pasteboard.createPlainTextData(textData)
339bc03f14fSopenharmony_ci        
340bc03f14fSopenharmony_ciconsole.log('Writes PasteData to the pasteboard')
341bc03f14fSopenharmony_cisystemPasteboard.setPasteData(pasteData)
342bc03f14fSopenharmony_ci        
343bc03f14fSopenharmony_ciconsole.log('Checks there is content in the pasteboard')
344bc03f14fSopenharmony_ciassert.equal(systemPasteboard.hasPasteData(), true)
345bc03f14fSopenharmony_ci        
346bc03f14fSopenharmony_ciconsole.log('Checks the number of records')
347bc03f14fSopenharmony_cipasteData = systemPasteboard.getPasteData()
348bc03f14fSopenharmony_ciassert.equal(pasteData.getRecordCount(), 1)
349bc03f14fSopenharmony_ci        
350bc03f14fSopenharmony_ciconsole.log('Checks the pasteboard content')
351bc03f14fSopenharmony_ciassert.equal(pasteData.getPrimaryText(), textData)
352bc03f14fSopenharmony_ci        
353bc03f14fSopenharmony_ciconsole.log('Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data')
354bc03f14fSopenharmony_ciassert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_PLAIN), true)
355bc03f14fSopenharmony_ciassert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_PLAIN)
356bc03f14fSopenharmony_ci
357bc03f14fSopenharmony_ci//clipboard change listener
358bc03f14fSopenharmony_ciconsole.log('Off the content changes')
359bc03f14fSopenharmony_civar systemPasteboard = pasteboard.getSystemPasteboard()
360bc03f14fSopenharmony_cisystemPasteboard.off(contentChanges)
361bc03f14fSopenharmony_cisystemPasteboard.clear()
362bc03f14fSopenharmony_ci        
363bc03f14fSopenharmony_civar textData = 'Hello World!'
364bc03f14fSopenharmony_ciconsole.log('createUriData = ' + textData)
365bc03f14fSopenharmony_civar pasteData = pasteboard.createUriData(textData)
366bc03f14fSopenharmony_ci        
367bc03f14fSopenharmony_ciconsole.log('Writes PasteData to the pasteboard')
368bc03f14fSopenharmony_cisystemPasteboard.setPasteData(pasteData)
369bc03f14fSopenharmony_ci        
370bc03f14fSopenharmony_ciconsole.log('Checks there is content in the pasteboard')
371bc03f14fSopenharmony_ciassert.equal(systemPasteboard.hasPasteData(), true)
372bc03f14fSopenharmony_ci        
373bc03f14fSopenharmony_ciconsole.log('Checks the number of records')
374bc03f14fSopenharmony_cipasteData = systemPasteboard.getPasteData()
375bc03f14fSopenharmony_ciassert.equal(pasteData.getRecordCount(), 1)
376bc03f14fSopenharmony_ci        
377bc03f14fSopenharmony_ciconsole.log('On the content changes')
378bc03f14fSopenharmony_cisystemPasteboard.on(contentChanges)
379bc03f14fSopenharmony_ci        
380bc03f14fSopenharmony_ciconsole.log('Removes the Record')
381bc03f14fSopenharmony_ciassert.equal(pasteData.removeRecordAt(0), true)
382bc03f14fSopenharmony_ci        
383bc03f14fSopenharmony_ciconsole.log('Writes PasteData to the pasteboard')
384bc03f14fSopenharmony_cisystemPasteboard.setPasteData(pasteData)
385bc03f14fSopenharmony_ci        
386bc03f14fSopenharmony_ciconsole.log('Checks the number of records')
387bc03f14fSopenharmony_cipasteData = systemPasteboard.getPasteData()
388bc03f14fSopenharmony_ciassert.equal(pasteData.getRecordCount(), 0)
389bc03f14fSopenharmony_ci        
390bc03f14fSopenharmony_ciconsole.log('Checks there is  no content in the pasteboard')
391bc03f14fSopenharmony_ciassert.equal(systemPasteboard.hasPasteData(), false)
392bc03f14fSopenharmony_ci        
393bc03f14fSopenharmony_civar textDataNew = 'Hello World!-New'
394bc03f14fSopenharmony_ciconsole.log('createUriData = ' + textDataNew)
395bc03f14fSopenharmony_civar pasteData = pasteboard.createUriData(textDataNew)
396bc03f14fSopenharmony_ci        
397bc03f14fSopenharmony_ciconsole.log('Writes PasteData to the pasteboard')
398bc03f14fSopenharmony_cisystemPasteboard.setPasteData(pasteData)
399bc03f14fSopenharmony_ci        
400bc03f14fSopenharmony_ciconsole.log('Checks there is content in the pasteboard')
401bc03f14fSopenharmony_ciassert.equal(systemPasteboard.hasPasteData(), true)
402bc03f14fSopenharmony_ci        
403bc03f14fSopenharmony_ciconsole.log('Checks the number of records')
404bc03f14fSopenharmony_cipasteData = systemPasteboard.getPasteData()
405bc03f14fSopenharmony_ciassert.equal(pasteData.getRecordCount(), 1)
406bc03f14fSopenharmony_ci        
407bc03f14fSopenharmony_ciconsole.log('Checks the pasteboard content')
408bc03f14fSopenharmony_ciassert.equal(pasteData.getRecordAt(0).plainText, textDataNew)
409bc03f14fSopenharmony_ci
410bc03f14fSopenharmony_ci```
411bc03f14fSopenharmony_ci
412bc03f14fSopenharmony_ci
413bc03f14fSopenharmony_ci
414bc03f14fSopenharmony_ci## Related warehouse
415bc03f14fSopenharmony_ci
416bc03f14fSopenharmony_ci**Distributed Data Management subsystem**
417bc03f14fSopenharmony_ci
418bc03f14fSopenharmony_ci[distributeddatamgr\_pasteboard](https://gitee.com/openharmony/distributeddatamgr_pasteboard)
419bc03f14fSopenharmony_ci
420