> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createData](#pasteboardcreatedata9).
Creates a **PasteData** object of the pixel map type.
Creates a **PasteData** object of the Want type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createData](#pasteboardcreatedata9).
Creates a **PasteData** object of the plain text type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createData](#pasteboardcreatedata9).
Creates a **PasteDataRecord** object of the plain text type.
Creates a **PasteData** object of the URI type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createData](#pasteboardcreatedata9).
Creates a **PasteDataRecord** object of the HTML text type.
Creates a **PasteDataRecord** object of the HTML text type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createRecord](#pasteboardcreaterecord9).
Creates a **PasteDataRecord** object of the Want type.
Creates a **PasteDataRecord** object of the Want type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createRecord](#pasteboardcreaterecord9).
Creates a **PasteDataRecord** object of the pixel map type.
Creates a **PasteDataRecord** object of the plain text type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createRecord](#pasteboardcreaterecord9).
Creates a **PasteDataRecord** object of the custom type.
Creates a **PasteDataRecord** object of the URI type.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [pasteboard.createRecord](#pasteboardcreaterecord9).
| InApp |Only intra-application pasting is allowed. |
| LocalDevice |Paste is allowed in any application on the local device. |
| CrossDevice |Paste is allowed in any application across devices. |
## PasteDataProperty<sup>7+</sup>
## PasteDataProperty<sup>7+</sup>
...
@@ -434,12 +383,10 @@ Defines the properties of all data records on the pasteboard, including the time
...
@@ -434,12 +383,10 @@ Defines the properties of all data records on the pasteboard, including the time
| localOnly<sup>7+</sup> | boolean | Yes| Yes| Whether the pasteboard content is set for local access only. The default value is **true**.<br>- **true**: The pasteboard content is set for local access only.<br>- **false**: The pasteboard content can be shared between devices.|
| localOnly<sup>7+</sup> | boolean | Yes| Yes| Whether the pasteboard content is set for local access only. The default value is **true**.<br>- **true**: The pasteboard content is set for local access only.<br>- **false**: The pasteboard content can be shared between devices.|
| shareOption<sup>9+</sup> | [ShareOption](#shareoption9) | Yes| Yes| Where the pasteboard content can be pasted. If this attribute is set incorrectly or not set, the default value **CrossDevice** is used.|
| shareOption<sup>9+</sup> | [ShareOption](#shareoption9) | Yes| Yes| Where the pasteboard content can be pasted. If this attribute is set incorrectly or not set, the default value **CrossDevice** is used.|
## PasteDataRecord<sup>7+</sup>
## PasteDataRecord<sup>7+</sup>
Provides **PasteDataRecord** APIs. A **PasteDataRecord** is an abstract definition of the content on the pasteboard. The pasteboard content consists of one or more plain text, HTML, URI, or Want records.
Provides **PasteDataRecord** APIs. A **PasteDataRecord** is an abstract definition of the content on the pasteboard. The pasteboard content consists of one or more plain text, HTML, URI, or Want records.
| callback | AsyncCallback<string> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the text obtained from the conversion. Otherwise, **err** is error information.|
Adds a plain text record to this pasteboard, and adds **MIME_TEXT_PLAIN** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
Adds a data record to this pasteboard, and adds its type to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
The pasteboard supports a maximum number of 512 data records.
The pasteboard supports a maximum number of 512 data records.
...
@@ -662,130 +655,21 @@ The pasteboard supports a maximum number of 512 data records.
...
@@ -662,130 +655,21 @@ The pasteboard supports a maximum number of 512 data records.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| text | string | Yes| Plain text.|
| record | [PasteDataRecord](#pastedatarecord7) | Yes| Record to add.|
Adds an HTML record to this pasteboard, and adds **MIMETYPE_TEXT_HTML** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
The pasteboard supports a maximum number of 512 data records.
Adds a Want record to this pasteboard, and adds **MIMETYPE_TEXT_WANT** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
The pasteboard supports a maximum number of 512 data records.
Adds a URI record to this pasteboard, and adds **MIMETYPE_TEXT_URI** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
The pasteboard supports a maximum number of 512 data records.
Adds a pixel map record to this pasteboard, and adds **MIMETYPE_PIXELMAP** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
The pasteboard supports a maximum number of 512 data records.
Adds a custom-type record to this pasteboard, and adds the custom type to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
Adds a custom-type record to this pasteboard, and adds the custom type to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
...
@@ -798,44 +682,23 @@ The pasteboard supports a maximum number of 512 data records.
...
@@ -798,44 +682,23 @@ The pasteboard supports a maximum number of 512 data records.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| mimeType | string | Yes| MIME type of custom data.|
| mimeType | string | Yes| MIME type of custom data.|
| value | ArrayBuffer | Yes| Content of custom data.|
| value | [ValueType](#valuetype9) | Yes| Content of custom data.|
Adds a data record to this pasteboard, and adds its type to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
The pasteboard supports a maximum number of 512 data records.
Adds an HTML record to this pasteboard, and adds **MIMETYPE_TEXT_HTML** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
Before calling any **SystemPasteboard** API, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard).
The pasteboard supports a maximum number of 512 data records.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [addRecord](#addrecord9).
Adds a Want record to this pasteboard, and adds **MIMETYPE_TEXT_WANT** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
Writes a **PasteData** object to the pasteboard. This API uses an asynchronous callback to return the result.
The pasteboard supports a maximum number of 512 data records.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [addRecord](#addrecord9).
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
Adds a plain text record to this pasteboard, and adds **MIME_TEXT_PLAIN** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
Writes a **PasteData** object to the pasteboard. This API uses a promise to return the result.
The pasteboard supports a maximum number of 512 data records.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [addRecord](#addrecord9).
Adds a URI record to this pasteboard, and adds **MIMETYPE_TEXT_URI** to **mimeTypes** in [PasteDataProperty](#pastedataproperty7). The parameters cannot be empty. Otherwise, the operation fails.
Obtains a **PasteData** object from the pasteboard. This API uses an asynchronous callback to return the result.
The pasteboard supports a maximum number of 512 data records.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [addRecord](#addrecord9).
@@ -1170,53 +1049,52 @@ Obtains a **PasteData** object from the pasteboard. This API uses an asynchronou
...
@@ -1170,53 +1049,52 @@ Obtains a **PasteData** object from the pasteboard. This API uses an asynchronou
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[PasteData](#pastedata)> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the system pasteboard data. Otherwise, **err** is an error object.|
Before calling any **SystemPasteboard** API, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard).
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
| data | [PasteData](#pastedata) | Yes| **PasteData** object.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Pasteboard Error Codes](../errorcodes/errorcode-pasteboard.md).
| Error Code ID| Error Message|
| -------- | -------- |
| 12900003 | Another copy or paste is in progress. |
| callback | AsyncCallback<[PasteData](#pastedata)> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the system pasteboard data. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Pasteboard Error Codes](../errorcodes/errorcode-pasteboard.md).
| Error Code ID| Error Message|
| -------- | -------- |
| 12900003 | Another copy or paste is in progress. |
| callback | AsyncCallback<[PasteData](#pastedata)> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the system pasteboard data. Otherwise, **err** is an error object.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if the system pasteboard contains data; returns **false** otherwise.|
**Example**
```js
systemPasteboard.hasPasteData((err,data)=>{
if(err){
console.error(`Failed to check the PasteData. Cause: ${err.message}`);
return;
}
console.info(`Succeeded in checking the PasteData. Data: ${data}`);
});
```
### hasPasteData<sup>(deprecated)</sup>
hasPasteData(): Promise<boolean>
Checks whether the system pasteboard contains data. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [hasData](#hasdata9-1).
| data | [PasteData](#pastedata) | Yes| **PasteData** object.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
This error code is reported when the index passed in to the called API, such as **getRecord**, is out of range.
**Possible Causes**
The index passed in the API is beyond the record index range of the **PasteData** object. For example, the index passed in to **getRecord** exceeds the number of records.
**Solution**
Check the index range and call the API again with a valid index.
## 12900002 Maximum Number of Records Reached
**Error Message**
The number of record exceeds the maximum limit.
**Description**
This error code is reported when no new **PasteData** record can be added.
**Possible Causes**
The number of **PasteData** records has reached the maximum.
**Solution**
1. Check whether the number of **PasteData** records has reached the maximum.
2. If the number of **PasteData** records has reached the maximum, delete some records before adding new ones.
## 12900003 Another Copy or Paste Operation in Progress
**Error Message**
Another copy or paste is in progress.
**Description**
This error code is reported when a new copy or paste attempt is made before the previous one is completed.
**Possible Causes**
The copy and paste APIs are both asynchronous APIs. If the data to be copied or pasted is in large amount, the time required may be long. New copy or paste operations can be performed only after the previous operations have been completed.
**Solution**
1. Before copying or pasting data, check the status of the last copy or paste operation.
2. Perform subsequent operations only after the previous copy/paste operation is completed.
## 12900004 Copy Prohibited
**Error Message**
Replication is prohibited.
**Description**
This error code is reported when an attempt is made to copy data that cannot be copied.
**Possible Causes**
The target data cannot be copied, such as read-only data.