提交 1e6c0019 编写于 作者: Q qimeng

Signed-off-by: qimeng <qimeng11@huawei.com>

 Changes to be committed:
	modified:   zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
上级 899ef1b5
...@@ -16,14 +16,14 @@ import pasteboard from '@ohos.pasteboard'; ...@@ -16,14 +16,14 @@ import pasteboard from '@ohos.pasteboard';
**系统能力:** SystemCapability.MiscServices.Pasteboard **系统能力:** SystemCapability.MiscServices.Pasteboard
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| MAX_RECORD_NUM<sup>7+</sup> | number | 是 | 否 | 单个PasteData中所能包含的最大条目数。 | | MAX_RECORD_NUM<sup>7+</sup> | number | 512 | 单个PasteData中所能包含的最大条目数。 |
| MIMETYPE_TEXT_HTML<sup>7+</sup> | string | 是 | 否 | HTML内容的MIME类型定义。 | | MIMETYPE_TEXT_HTML<sup>7+</sup> | string | text/html | HTML内容的MIME类型定义。 |
| MIMETYPE_TEXT_WANT<sup>7+</sup> | string | 是 | 否 | Want内容的MIME类型定义。 | | MIMETYPE_TEXT_WANT<sup>7+</sup> | string | text/want | Want内容的MIME类型定义。 |
| MIMETYPE_TEXT_PLAIN<sup>7+</sup> | string | 是 | 否 | 纯文本内容的MIME类型定义。 | | MIMETYPE_TEXT_PLAIN<sup>7+</sup> | string | text/plain | 纯文本内容的MIME类型定义。 |
| MIMETYPE_TEXT_URI<sup>7+</sup> | string | 是 | 否 | URI内容的MIME类型定义。 | | MIMETYPE_TEXT_URI<sup>7+</sup> | string | text/uri | URI内容的MIME类型定义。 |
| MIMETYPE_PIXELMAP<sup>9+</sup> | string | 是 | 否 | PixelMap内容的MIME类型定义。 | | MIMETYPE_PIXELMAP<sup>9+</sup> | string | pixelMap | PixelMap内容的MIME类型定义。 |
## ValueType<sup>9+</sup> ## ValueType<sup>9+</sup>
...@@ -62,8 +62,8 @@ createData(mimeType: string, value: ValueType): PasteData ...@@ -62,8 +62,8 @@ createData(mimeType: string, value: ValueType): PasteData
**示例:** **示例:**
```js ```js
var dataXml = 'aStringValueType'; let dataXml = new ArrayBuffer(256);
var pasteData = pasteboard.createData('app/xml', dataXml); let pasteData = pasteboard.createData('app/xml', dataXml);
``` ```
## pasteboard.createRecord<sup>9+</sup> ## pasteboard.createRecord<sup>9+</sup>
...@@ -90,8 +90,8 @@ createRecord(mimeType: string, value: ValueType):PasteDataRecord; ...@@ -90,8 +90,8 @@ createRecord(mimeType: string, value: ValueType):PasteDataRecord;
**示例:** **示例:**
```js ```js
var dataXml = 'aStringValueType'; let dataXml = new ArrayBuffer(256);
var pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); let pasteDataRecord = pasteboard.createRecord('app/xml', dataXml);
``` ```
## pasteboard.getSystemPasteboard ## pasteboard.getSystemPasteboard
...@@ -111,7 +111,7 @@ getSystemPasteboard(): SystemPasteboard ...@@ -111,7 +111,7 @@ getSystemPasteboard(): SystemPasteboard
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
## ShareOption<sup>9+</sup> ## ShareOption<sup>9+</sup>
...@@ -152,8 +152,8 @@ createHtmlData(htmlText: string): PasteData ...@@ -152,8 +152,8 @@ createHtmlData(htmlText: string): PasteData
**示例:** **示例:**
```js ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); let pasteData = pasteboard.createHtmlData(html);
``` ```
## pasteboard.createWantData<sup>(deprecated)</sup> ## pasteboard.createWantData<sup>(deprecated)</sup>
...@@ -182,11 +182,11 @@ createWantData(want: Want): PasteData ...@@ -182,11 +182,11 @@ createWantData(want: Want): PasteData
**示例:** **示例:**
```js ```js
var object = { let object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var pasteData = pasteboard.createWantData(object); let pasteData = pasteboard.createWantData(object);
``` ```
## pasteboard.createPlainTextData<sup>(deprecated)</sup> ## pasteboard.createPlainTextData<sup>(deprecated)</sup>
...@@ -215,7 +215,7 @@ createPlainTextData(text: string): PasteData ...@@ -215,7 +215,7 @@ createPlainTextData(text: string): PasteData
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); let pasteData = pasteboard.createPlainTextData('content');
``` ```
## pasteboard.createUriData<sup>(deprecated)</sup> ## pasteboard.createUriData<sup>(deprecated)</sup>
...@@ -244,7 +244,7 @@ createUriData(uri: string): PasteData ...@@ -244,7 +244,7 @@ createUriData(uri: string): PasteData
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt');
``` ```
## pasteboard.createHtmlTextRecord<sup>(deprecated)</sup> ## pasteboard.createHtmlTextRecord<sup>(deprecated)</sup>
...@@ -272,8 +272,8 @@ createHtmlTextRecord(htmlText: string): PasteDataRecord ...@@ -272,8 +272,8 @@ createHtmlTextRecord(htmlText: string): PasteDataRecord
**示例:** **示例:**
```js ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var record = pasteboard.createHtmlTextRecord(html); let record = pasteboard.createHtmlTextRecord(html);
``` ```
## pasteboard.createWantRecord<sup>(deprecated)</sup> ## pasteboard.createWantRecord<sup>(deprecated)</sup>
...@@ -302,11 +302,11 @@ createWantRecord(want: Want): PasteDataRecord ...@@ -302,11 +302,11 @@ createWantRecord(want: Want): PasteDataRecord
**示例:** **示例:**
```js ```js
var object = { let object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var record = pasteboard.createWantRecord(object); let record = pasteboard.createWantRecord(object);
``` ```
## pasteboard.createPlainTextRecord<sup>(deprecated)</sup> ## pasteboard.createPlainTextRecord<sup>(deprecated)</sup>
...@@ -335,7 +335,7 @@ createPlainTextRecord(text: string): PasteDataRecord ...@@ -335,7 +335,7 @@ createPlainTextRecord(text: string): PasteDataRecord
**示例:** **示例:**
```js ```js
var record = pasteboard.createPlainTextRecord("hello"); let record = pasteboard.createPlainTextRecord('hello');
``` ```
## pasteboard.createUriRecord<sup>(deprecated)</sup> ## pasteboard.createUriRecord<sup>(deprecated)</sup>
...@@ -364,7 +364,7 @@ createUriRecord(uri: string): PasteDataRecord ...@@ -364,7 +364,7 @@ createUriRecord(uri: string): PasteDataRecord
**示例:** **示例:**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
``` ```
...@@ -418,13 +418,13 @@ convertToTextV9(callback: AsyncCallback&lt;string&gt;): void ...@@ -418,13 +418,13 @@ convertToTextV9(callback: AsyncCallback&lt;string&gt;): void
**示例:** **示例:**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
record.convertToTextV9((err, data) => { record.convertToTextV9((err, data) => {
if (err) { if (err) {
console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); console.error('Failed to convert to text. Cause: ${err.message}');
return; return;
} }
console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); console.info('Succeeded in converting to text. Data: ${data}');
}); });
``` ```
...@@ -445,11 +445,11 @@ convertToTextV9(): Promise&lt;string&gt; ...@@ -445,11 +445,11 @@ convertToTextV9(): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
record.convertToTextV9().then((data) => { record.convertToTextV9().then((data) => {
console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); console.info('Succeeded in converting to text. Data: ${data}');
}).catch((err) => { }).catch((err) => {
console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); console.error('Failed to convert to text. Cause: ${err.message}');
}); });
``` ```
...@@ -473,13 +473,13 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void ...@@ -473,13 +473,13 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void
**示例:** **示例:**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
record.convertToText((err, data) => { record.convertToText((err, data) => {
if (err) { if (err) {
console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); console.error('Failed to convert to text. Cause: ${err.message}');
return; return;
} }
console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); console.info('Succeeded in converting to text. Data: ${data}');
}); });
``` ```
...@@ -503,11 +503,11 @@ convertToText(): Promise&lt;string&gt; ...@@ -503,11 +503,11 @@ convertToText(): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
record.convertToText().then((data) => { record.convertToText().then((data) => {
console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); console.info('Succeeded in converting to text. Data: ${data}');
}).catch((err) => { }).catch((err) => {
console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); console.error('Failed to convert to text. Cause: ${err.message}');
}); });
``` ```
...@@ -536,8 +536,8 @@ getPrimaryText(): string ...@@ -536,8 +536,8 @@ getPrimaryText(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var plainText = pasteData.getPrimaryText(); let plainText = pasteData.getPrimaryText();
``` ```
### getPrimaryHtml<sup>7+</sup> ### getPrimaryHtml<sup>7+</sup>
...@@ -557,9 +557,9 @@ getPrimaryHtml(): string ...@@ -557,9 +557,9 @@ getPrimaryHtml(): string
**示例:** **示例:**
```js ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); let pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml(); let htmlText = pasteData.getPrimaryHtml();
``` ```
### getPrimaryWant<sup>7+</sup> ### getPrimaryWant<sup>7+</sup>
...@@ -579,12 +579,12 @@ getPrimaryWant(): Want ...@@ -579,12 +579,12 @@ getPrimaryWant(): Want
**示例:** **示例:**
```js ```js
var object = { let object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var pasteData = pasteboard.createWantData(object); let pasteData = pasteboard.createWantData(object);
var want = pasteData.getPrimaryWant(); let want = pasteData.getPrimaryWant();
``` ```
### getPrimaryUri<sup>7+</sup> ### getPrimaryUri<sup>7+</sup>
...@@ -604,8 +604,8 @@ getPrimaryUri(): string ...@@ -604,8 +604,8 @@ getPrimaryUri(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt');
var uri = pasteData.getPrimaryUri(); let uri = pasteData.getPrimaryUri();
``` ```
### getPrimaryPixelMap<sup>9+</sup> ### getPrimaryPixelMap<sup>9+</sup>
...@@ -627,18 +627,18 @@ getPrimaryPixelMap(): image.PixelMap ...@@ -627,18 +627,18 @@ getPrimaryPixelMap(): image.PixelMap
```js ```js
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
var buffer = new ArrayBuffer(128) let buffer = new ArrayBuffer(128);
var opt = { let opt = {
size: { height: 3, width: 5 }, size: { height: 3, width: 5 },
pixelFormat: 3, pixelFormat: 3,
editable: true, editable: true,
alphaType: 1, alphaType: 1,
scaleMode: 1 scaleMode: 1
} };
image.createPixelMap(buffer, opt).then((pixelMap) => { image.createPixelMap(buffer, opt).then((pixelMap) => {
var pasteData = pasteboard.createPixelMapData(pixelMap); let pasteData = pasteboard.createPixelMapData(pixelMap);
var pixelMap = pasteData.getPrimaryPixelMap(); let pixelMap = pasteData.getPrimaryPixelMap();
}) });
``` ```
### addRecord<sup>7+</sup> ### addRecord<sup>7+</sup>
...@@ -660,10 +660,10 @@ addRecord(record: PasteDataRecord): void ...@@ -660,10 +660,10 @@ addRecord(record: PasteDataRecord): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt');
var textRecord = pasteboard.createPlainTextRecord("hello"); let textRecord = pasteboard.createPlainTextRecord('hello');
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var htmlRecord = pasteboard.createHtmlTextRecord(html); let htmlRecord = pasteboard.createHtmlTextRecord(html);
pasteData.addRecord(textRecord); pasteData.addRecord(textRecord);
pasteData.addRecord(htmlRecord); pasteData.addRecord(htmlRecord);
``` ```
...@@ -694,8 +694,8 @@ addRecord(mimeType: string, value: ValueType): void ...@@ -694,8 +694,8 @@ addRecord(mimeType: string, value: ValueType): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt');
var dataXml = 'aStringValueType'; let dataXml = new ArrayBuffer(256);
pasteData.addRecord('app/xml', dataXml); pasteData.addRecord('app/xml', dataXml);
``` ```
...@@ -716,8 +716,8 @@ getMimeTypes(): Array&lt;string&gt; ...@@ -716,8 +716,8 @@ getMimeTypes(): Array&lt;string&gt;
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var types = pasteData.getMimeTypes(); let types = pasteData.getMimeTypes();
``` ```
### getPrimaryMimeType<sup>7+</sup> ### getPrimaryMimeType<sup>7+</sup>
...@@ -737,8 +737,8 @@ getPrimaryMimeType(): string ...@@ -737,8 +737,8 @@ getPrimaryMimeType(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var type = pasteData.getPrimaryMimeType(); let type = pasteData.getPrimaryMimeType();
``` ```
### getProperty<sup>7+</sup> ### getProperty<sup>7+</sup>
...@@ -758,8 +758,8 @@ getProperty(): PasteDataProperty ...@@ -758,8 +758,8 @@ getProperty(): PasteDataProperty
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var property = pasteData.getProperty(); let property = pasteData.getProperty();
``` ```
### setProperty<sup>9+</sup> ### setProperty<sup>9+</sup>
...@@ -779,7 +779,7 @@ setProperty(property: PasteDataProperty): void ...@@ -779,7 +779,7 @@ setProperty(property: PasteDataProperty): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createHtmlData('application/xml'); let pasteData = pasteboard.createHtmlData('application/xml');
let prop = pasteData.getProperty(); let prop = pasteData.getProperty();
prop.shareOption = pasteboard.ShareOption.InApp; prop.shareOption = pasteboard.ShareOption.InApp;
pasteData.setProperty(prop); pasteData.setProperty(prop);
...@@ -815,8 +815,8 @@ getRecord(index: number): PasteDataRecord ...@@ -815,8 +815,8 @@ getRecord(index: number): PasteDataRecord
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var record = pasteData.getRecord(0); let record = pasteData.getRecord(0);
``` ```
### getRecordCount<sup>7+</sup> ### getRecordCount<sup>7+</sup>
...@@ -836,8 +836,8 @@ getRecordCount(): number ...@@ -836,8 +836,8 @@ getRecordCount(): number
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var count = pasteData.getRecordCount(); let count = pasteData.getRecordCount();
``` ```
### getTag<sup>7+</sup> ### getTag<sup>7+</sup>
...@@ -857,8 +857,8 @@ getTag(): string ...@@ -857,8 +857,8 @@ getTag(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var tag = pasteData.getTag(); let tag = pasteData.getTag();
``` ```
### hasType<sup>9+</sup> ### hasType<sup>9+</sup>
...@@ -884,8 +884,8 @@ hasType(mimeType: string): boolean ...@@ -884,8 +884,8 @@ hasType(mimeType: string): boolean
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN); let hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
### removeRecord<sup>9+</sup> ### removeRecord<sup>9+</sup>
...@@ -912,7 +912,7 @@ removeRecord(index: number): void ...@@ -912,7 +912,7 @@ removeRecord(index: number): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
pasteData.removeRecord(0); pasteData.removeRecord(0);
``` ```
...@@ -941,8 +941,8 @@ replaceRecord(index: number, record: PasteDataRecord): void ...@@ -941,8 +941,8 @@ replaceRecord(index: number, record: PasteDataRecord): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
pasteData.replaceRecord(0, record); pasteData.replaceRecord(0, record);
``` ```
### addHtmlRecord<sup>(deprecated)</sup> ### addHtmlRecord<sup>(deprecated)</sup>
...@@ -967,8 +967,8 @@ addHtmlRecord(htmlText: string): void ...@@ -967,8 +967,8 @@ addHtmlRecord(htmlText: string): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; let html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
pasteData.addHtmlRecord(html); pasteData.addHtmlRecord(html);
``` ```
...@@ -994,8 +994,8 @@ addWantRecord(want: Want): void ...@@ -994,8 +994,8 @@ addWantRecord(want: Want): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var object = { let object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
...@@ -1024,8 +1024,8 @@ addTextRecord(text: string): void ...@@ -1024,8 +1024,8 @@ addTextRecord(text: string): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
pasteData.addTextRecord("good"); pasteData.addTextRecord('good');
``` ```
### addUriRecord<sup>(deprecated)</sup> ### addUriRecord<sup>(deprecated)</sup>
...@@ -1050,8 +1050,8 @@ addUriRecord(uri: string): void ...@@ -1050,8 +1050,8 @@ addUriRecord(uri: string): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
pasteData.addUriRecord("dataability:///com.example.myapplication1/user.txt"); pasteData.addUriRecord('dataability:///com.example.myapplication1/user.txt');
``` ```
### getRecordAt<sup>(deprecated)</sup> ### getRecordAt<sup>(deprecated)</sup>
...@@ -1079,8 +1079,8 @@ getRecordAt(index: number): PasteDataRecord ...@@ -1079,8 +1079,8 @@ getRecordAt(index: number): PasteDataRecord
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var record = pasteData.getRecordAt(0); let record = pasteData.getRecordAt(0);
``` ```
### hasMimeType<sup>(deprecated)</sup> ### hasMimeType<sup>(deprecated)</sup>
...@@ -1109,8 +1109,8 @@ hasMimeType(mimeType: string): boolean ...@@ -1109,8 +1109,8 @@ hasMimeType(mimeType: string): boolean
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); let hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
### removeRecordAt<sup>(deprecated)</sup> ### removeRecordAt<sup>(deprecated)</sup>
...@@ -1138,8 +1138,8 @@ removeRecordAt(index: number): boolean ...@@ -1138,8 +1138,8 @@ removeRecordAt(index: number): boolean
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var isRemove = pasteData.removeRecordAt(0); let isRemove = pasteData.removeRecordAt(0);
``` ```
### replaceRecordAt<sup>(deprecated)</sup> ### replaceRecordAt<sup>(deprecated)</sup>
...@@ -1168,9 +1168,9 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean ...@@ -1168,9 +1168,9 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt');
var isReplace = pasteData.replaceRecordAt(0, record); let isReplace = pasteData.replaceRecordAt(0, record);
``` ```
## SystemPasteboard ## SystemPasteboard
...@@ -1180,7 +1180,7 @@ var isReplace = pasteData.replaceRecordAt(0, record); ...@@ -1180,7 +1180,7 @@ var isReplace = pasteData.replaceRecordAt(0, record);
在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。 在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
### on('update')<sup>7+</sup> ### on('update')<sup>7+</sup>
...@@ -1201,8 +1201,8 @@ on(type: 'update', callback: () =&gt;void ): void ...@@ -1201,8 +1201,8 @@ on(type: 'update', callback: () =&gt;void ): void
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
var listener = () => { let listener = () => {
console.info('The system pasteboard has changed.'); console.info('The system pasteboard has changed.');
}; };
systemPasteboard.on('update', listener); systemPasteboard.on('update', listener);
...@@ -1228,7 +1228,7 @@ off(type: 'update', callback?: () =&gt;void ): void ...@@ -1228,7 +1228,7 @@ off(type: 'update', callback?: () =&gt;void ): void
```js ```js
let listener = () => { let listener = () => {
console.info('The system pasteboard has changed.'); console.info('The system pasteboard has changed.');
}; };
systemPasteboard.off('update', listener); systemPasteboard.off('update', listener);
``` ```
...@@ -1250,9 +1250,9 @@ clearData(callback: AsyncCallback&lt;void&gt;): void ...@@ -1250,9 +1250,9 @@ clearData(callback: AsyncCallback&lt;void&gt;): void
```js ```js
systemPasteboard.clearData((err, data) => { systemPasteboard.clearData((err, data) => {
if (err) { if (err) {
console.error('Failed to clear the pasteboard. Cause: ' + JSON.stringify(err)); console.error('Failed to clear the pasteboard. Cause: ${err.message}');
return; return;
} }
console.info('Succeeded in clearing the pasteboard.'); console.info('Succeeded in clearing the pasteboard.');
}); });
...@@ -1278,7 +1278,7 @@ clearData(): Promise&lt;void&gt; ...@@ -1278,7 +1278,7 @@ clearData(): Promise&lt;void&gt;
systemPasteboard.clearData().then((data) => { systemPasteboard.clearData().then((data) => {
console.info('Succeeded in clearing the pasteboard.'); console.info('Succeeded in clearing the pasteboard.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to clear the pasteboard. Cause: ' + JSON.stringify(err)); console.error('Failed to clear the pasteboard. Cause: ${err.message}');
}); });
``` ```
...@@ -1308,8 +1308,8 @@ setData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void ...@@ -1308,8 +1308,8 @@ setData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); let pasteData = pasteboard.createPlainTextData('content');
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData, (err, data) => { systemPasteboard.setData(pasteData, (err, data) => {
if (err) { if (err) {
console.error('Failed to set PasteData. Cause: ' + err.message); console.error('Failed to set PasteData. Cause: ' + err.message);
...@@ -1350,8 +1350,8 @@ setData(data: PasteData): Promise&lt;void&gt; ...@@ -1350,8 +1350,8 @@ setData(data: PasteData): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); let pasteData = pasteboard.createPlainTextData('content');
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setData(pasteData).then((data) => { systemPasteboard.setData(pasteData).then((data) => {
console.info('Succeeded in setting PasteData.'); console.info('Succeeded in setting PasteData.');
}).catch((err) => { }).catch((err) => {
...@@ -1383,13 +1383,13 @@ getData( callback: AsyncCallback&lt;PasteData&gt;): void ...@@ -1383,13 +1383,13 @@ getData( callback: AsyncCallback&lt;PasteData&gt;): void
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getData((err, pasteData) => { systemPasteboard.getData((err, pasteData) => {
if (err) { if (err) {
console.error('Failed to get PasteData. Cause: ' + err.message); console.error('Failed to get PasteData. Cause: ' + err.message);
return; return;
} }
var text = pasteData.getPrimaryText(); let text = pasteData.getPrimaryText();
}); });
``` ```
...@@ -1417,9 +1417,9 @@ getData(): Promise&lt;PasteData&gt; ...@@ -1417,9 +1417,9 @@ getData(): Promise&lt;PasteData&gt;
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getData().then((pasteData) => { systemPasteboard.getData().then((pasteData) => {
var text = pasteData.getPrimaryText(); let text = pasteData.getPrimaryText();
}).catch((err) => { }).catch((err) => {
console.error('Failed to get PasteData. Cause: ' + err.message); console.error('Failed to get PasteData. Cause: ' + err.message);
}) })
...@@ -1444,10 +1444,10 @@ hasData(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1444,10 +1444,10 @@ hasData(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
systemPasteboard.hasData((err, data) => { systemPasteboard.hasData((err, data) => {
if (err) { if (err) {
console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); console.error('Failed to check the PasteData. Cause: ${err.message}');
return; return;
} }
console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking the PasteData. Data: ${data}');
}); });
``` ```
...@@ -1469,9 +1469,9 @@ hasData(): Promise&lt;boolean&gt; ...@@ -1469,9 +1469,9 @@ hasData(): Promise&lt;boolean&gt;
```js ```js
systemPasteboard.hasData().then((data) => { systemPasteboard.hasData().then((data) => {
console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking the PasteData. Data: ${data}');
}).catch((err) => { }).catch((err) => {
console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); console.error('Failed to check the PasteData. Cause: ${err.message}');
}); });
``` ```
...@@ -1497,8 +1497,8 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -1497,8 +1497,8 @@ clear(callback: AsyncCallback&lt;void&gt;): void
```js ```js
systemPasteboard.clear((err, data) => { systemPasteboard.clear((err, data) => {
if (err) { if (err) {
console.error('Failed to clear the PasteData. Cause: ' + JSON.stringify(err)); console.error('Failed to clear the PasteData. Cause: ${err.message}');
return; return;
} }
console.info('Succeeded in clearing the PasteData.'); console.info('Succeeded in clearing the PasteData.');
}); });
...@@ -1527,7 +1527,7 @@ clear(): Promise&lt;void&gt; ...@@ -1527,7 +1527,7 @@ clear(): Promise&lt;void&gt;
systemPasteboard.clear().then((data) => { systemPasteboard.clear().then((data) => {
console.info('Succeeded in clearing the PasteData.'); console.info('Succeeded in clearing the PasteData.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to clear the PasteData. Cause: ' + JSON.stringify(err)); console.error('Failed to clear the PasteData. Cause: ${err.message}');
}); });
``` ```
...@@ -1551,13 +1551,13 @@ getPasteData( callback: AsyncCallback&lt;PasteData&gt;): void ...@@ -1551,13 +1551,13 @@ getPasteData( callback: AsyncCallback&lt;PasteData&gt;): void
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData((err, pasteData) => { systemPasteboard.getPasteData((err, pasteData) => {
if (err) { if (err) {
console.error('Failed to get PasteData. Cause: ' + err.message); console.error('Failed to get PasteData. Cause: ' + err.message);
return; return;
} }
var text = pasteData.getPrimaryText(); let text = pasteData.getPrimaryText();
}); });
``` ```
...@@ -1581,9 +1581,9 @@ getPasteData(): Promise&lt;PasteData&gt; ...@@ -1581,9 +1581,9 @@ getPasteData(): Promise&lt;PasteData&gt;
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData().then((pasteData) => { systemPasteboard.getPasteData().then((pasteData) => {
var text = pasteData.getPrimaryText(); let text = pasteData.getPrimaryText();
}).catch((err) => { }).catch((err) => {
console.error('Failed to get PasteData. Cause: ' + err.message); console.error('Failed to get PasteData. Cause: ' + err.message);
}) })
...@@ -1611,10 +1611,10 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1611,10 +1611,10 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
systemPasteboard.hasPasteData((err, data) => { systemPasteboard.hasPasteData((err, data) => {
if (err) { if (err) {
console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); console.error('Failed to check the PasteData. Cause: ${err.message}');
return; return;
} }
console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking the PasteData. Data: ${data}');
}); });
``` ```
...@@ -1639,9 +1639,9 @@ hasPasteData(): Promise&lt;boolean&gt; ...@@ -1639,9 +1639,9 @@ hasPasteData(): Promise&lt;boolean&gt;
```js ```js
systemPasteboard.hasPasteData().then((data) => { systemPasteboard.hasPasteData().then((data) => {
console.info('Succeeded in checking the PasteData. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking the PasteData. Data: ${data}');
}).catch((err) => { }).catch((err) => {
console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); console.error('Failed to check the PasteData. Cause: ${err.message}');
}); });
``` ```
...@@ -1666,8 +1666,8 @@ setPasteData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void ...@@ -1666,8 +1666,8 @@ setPasteData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); let pasteData = pasteboard.createPlainTextData('content');
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData, (err, data) => { systemPasteboard.setPasteData(pasteData, (err, data) => {
if (err) { if (err) {
console.error('Failed to set PasteData. Cause: ' + err.message); console.error('Failed to set PasteData. Cause: ' + err.message);
...@@ -1702,8 +1702,8 @@ setPasteData(data: PasteData): Promise&lt;void&gt; ...@@ -1702,8 +1702,8 @@ setPasteData(data: PasteData): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); let pasteData = pasteboard.createPlainTextData('content');
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData).then((data) => { systemPasteboard.setPasteData(pasteData).then((data) => {
console.info('Succeeded in setting PasteData.'); console.info('Succeeded in setting PasteData.');
}).catch((err) => { }).catch((err) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册