未验证 提交 45d91f39 编写于 作者: O openharmony_ci 提交者: Gitee

!10878 [3.2beta3]修复剪贴板API参考中规范问题&属性/常量问题

Merge pull request !10878 from qimeng/OpenHarmony-3.2-Beta3
...@@ -12,18 +12,18 @@ ...@@ -12,18 +12,18 @@
import pasteboard from '@ohos.pasteboard'; 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类型定义。 |
## pasteboard.createPlainTextData ## pasteboard.createPlainTextData
...@@ -49,7 +49,7 @@ createPlainTextData(text: string): PasteData ...@@ -49,7 +49,7 @@ createPlainTextData(text: string): PasteData
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); let pasteData = pasteboard.createPlainTextData('content');
``` ```
...@@ -76,8 +76,8 @@ createHtmlData(htmlText: string): PasteData ...@@ -76,8 +76,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);
``` ```
...@@ -104,11 +104,11 @@ createWantData(want: Want): PasteData ...@@ -104,11 +104,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);
``` ```
...@@ -135,7 +135,7 @@ createUriData(uri: string): PasteData ...@@ -135,7 +135,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');
``` ```
...@@ -164,8 +164,8 @@ createPixelMapData(pixelMap: image.PixelMap): PasteData ...@@ -164,8 +164,8 @@ createPixelMapData(pixelMap: image.PixelMap): PasteData
```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,
...@@ -173,7 +173,7 @@ var opt = { ...@@ -173,7 +173,7 @@ var opt = {
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);
}) })
``` ```
...@@ -201,8 +201,8 @@ createData(mimeType: string, value: ArrayBuffer): PasteData; ...@@ -201,8 +201,8 @@ createData(mimeType: string, value: ArrayBuffer): PasteData;
**示例:** **示例:**
```js ```js
var dataXml = new ArrayBuffer(256) let dataXml = new ArrayBuffer(256);
var pasteData = pasteboard.createData('app/xml', dataXml) let pasteData = pasteboard.createData('app/xml', dataXml);
``` ```
...@@ -229,7 +229,7 @@ createPlainTextRecord(text: string): PasteDataRecord ...@@ -229,7 +229,7 @@ createPlainTextRecord(text: string): PasteDataRecord
**示例:** **示例:**
```js ```js
var record = pasteboard.createPlainTextRecord("hello"); let record = pasteboard.createPlainTextRecord('hello');
``` ```
...@@ -256,8 +256,8 @@ createHtmlTextRecord(htmlText: string): PasteDataRecord ...@@ -256,8 +256,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);
``` ```
...@@ -284,11 +284,11 @@ createWantRecord(want: Want): PasteDataRecord ...@@ -284,11 +284,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);
``` ```
...@@ -315,7 +315,7 @@ createUriRecord(uri: string): PasteDataRecord ...@@ -315,7 +315,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');
``` ```
...@@ -344,8 +344,8 @@ createPixelMapRecord(pixelMap: image.PixelMap): PasteDataRecord ...@@ -344,8 +344,8 @@ createPixelMapRecord(pixelMap: image.PixelMap): PasteDataRecord
```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,
...@@ -353,7 +353,7 @@ var opt = { ...@@ -353,7 +353,7 @@ var opt = {
scaleMode: 1 scaleMode: 1
} }
image.createPixelMap(buffer, opt).then((pixelMap) => { image.createPixelMap(buffer, opt).then((pixelMap) => {
var record = pasteboard.createPixelMapRecord(pixelMap); let record = pasteboard.createPixelMapRecord(pixelMap);
}) })
``` ```
...@@ -381,8 +381,8 @@ createRecord(mimeType: string, value: ArrayBuffer):PasteDataRecord; ...@@ -381,8 +381,8 @@ createRecord(mimeType: string, value: ArrayBuffer):PasteDataRecord;
**示例:** **示例:**
```js ```js
var dataXml = new ArrayBuffer(256) let dataXml = new ArrayBuffer(256);
var pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); let pasteDataRecord = pasteboard.createRecord('app/xml', dataXml);
``` ```
...@@ -403,7 +403,7 @@ getSystemPasteboard(): SystemPasteboard ...@@ -403,7 +403,7 @@ getSystemPasteboard(): SystemPasteboard
**示例:** **示例:**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
## ShareOption<sup>9+</sup> ## ShareOption<sup>9+</sup>
...@@ -472,11 +472,11 @@ convertToText(): Promise&lt;string&gt; ...@@ -472,11 +472,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}`);
}); });
``` ```
...@@ -498,13 +498,13 @@ convertToText(callback: AsyncCallback&lt;string&gt;): void ...@@ -498,13 +498,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}`);
}); });
``` ```
...@@ -538,8 +538,8 @@ getPrimaryText(): string ...@@ -538,8 +538,8 @@ getPrimaryText(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var plainText = pasteData.getPrimaryText(); let plainText = pasteData.getPrimaryText();
``` ```
...@@ -560,9 +560,9 @@ getPrimaryHtml(): string ...@@ -560,9 +560,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();
``` ```
...@@ -583,12 +583,12 @@ getPrimaryWant(): Want ...@@ -583,12 +583,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();
``` ```
...@@ -609,8 +609,8 @@ getPrimaryUri(): string ...@@ -609,8 +609,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();
``` ```
...@@ -633,8 +633,8 @@ getPrimaryPixelMap(): image.PixelMap ...@@ -633,8 +633,8 @@ 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,
...@@ -642,8 +642,8 @@ var opt = { ...@@ -642,8 +642,8 @@ var opt = {
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();
}) })
``` ```
...@@ -667,8 +667,8 @@ addTextRecord(text: string): void ...@@ -667,8 +667,8 @@ addTextRecord(text: string): void
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
pasteData.addTextRecord("good"); pasteData.addTextRecord('good');
``` ```
...@@ -691,8 +691,8 @@ addHtmlRecord(htmlText: string): void ...@@ -691,8 +691,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);
``` ```
...@@ -716,8 +716,8 @@ addWantRecord(want: Want): void ...@@ -716,8 +716,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"
}; };
...@@ -744,8 +744,8 @@ addUriRecord(uri: string): void ...@@ -744,8 +744,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');
``` ```
### addPixelMapRecord<sup>9+</sup> ### addPixelMapRecord<sup>9+</sup>
...@@ -769,8 +769,8 @@ addPixelMapRecord(pixelMap: image.PixelMap): void ...@@ -769,8 +769,8 @@ addPixelMapRecord(pixelMap: image.PixelMap): void
```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,
...@@ -778,7 +778,7 @@ var opt = { ...@@ -778,7 +778,7 @@ var opt = {
scaleMode: 1 scaleMode: 1
} }
image.createPixelMap(buffer, opt).then((pixelMap) => { image.createPixelMap(buffer, opt).then((pixelMap) => {
var record = pasteboard.createPlainTextData("hello").addPixelMapRecord(pixelMap); let record = pasteboard.createPlainTextData('hello').addPixelMapRecord(pixelMap);
}) })
``` ```
...@@ -803,8 +803,8 @@ addRecord(mimeType: string, value: ArrayBuffer): void ...@@ -803,8 +803,8 @@ addRecord(mimeType: string, value: ArrayBuffer): 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 = new ArrayBuffer(256) let dataXml = new ArrayBuffer(256);
pasteData.addRecord('app/xml', dataXml); pasteData.addRecord('app/xml', dataXml);
``` ```
...@@ -828,10 +828,10 @@ addRecord(record: PasteDataRecord): void ...@@ -828,10 +828,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);
``` ```
...@@ -854,8 +854,8 @@ getMimeTypes(): Array&lt;string&gt; ...@@ -854,8 +854,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();
``` ```
...@@ -876,8 +876,8 @@ getPrimaryMimeType(): string ...@@ -876,8 +876,8 @@ getPrimaryMimeType(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var type = pasteData.getPrimaryMimeType(); let type = pasteData.getPrimaryMimeType();
``` ```
...@@ -898,8 +898,8 @@ getProperty(): PasteDataProperty ...@@ -898,8 +898,8 @@ getProperty(): PasteDataProperty
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var property = pasteData.getProperty(); let property = pasteData.getProperty();
``` ```
...@@ -920,7 +920,7 @@ setProperty(property: PasteDataProperty): void ...@@ -920,7 +920,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);
...@@ -950,8 +950,8 @@ getRecordAt(index: number): PasteDataRecord ...@@ -950,8 +950,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);
``` ```
...@@ -972,8 +972,8 @@ getRecordCount(): number ...@@ -972,8 +972,8 @@ getRecordCount(): number
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var count = pasteData.getRecordCount(); let count = pasteData.getRecordCount();
``` ```
...@@ -994,8 +994,8 @@ getTag(): string ...@@ -994,8 +994,8 @@ getTag(): string
**示例:** **示例:**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); let pasteData = pasteboard.createPlainTextData('hello');
var tag = pasteData.getTag(); let tag = pasteData.getTag();
``` ```
...@@ -1022,8 +1022,8 @@ hasMimeType(mimeType: string): boolean ...@@ -1022,8 +1022,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);
``` ```
...@@ -1050,8 +1050,8 @@ removeRecordAt(index: number): boolean ...@@ -1050,8 +1050,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);
``` ```
...@@ -1079,9 +1079,9 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean ...@@ -1079,9 +1079,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
...@@ -1091,7 +1091,7 @@ var isReplace = pasteData.replaceRecordAt(0, record); ...@@ -1091,7 +1091,7 @@ var isReplace = pasteData.replaceRecordAt(0, record);
在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。 在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); let systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
...@@ -1113,8 +1113,8 @@ setPasteData(data: PasteData, callback: AsyncCallback&lt;void&gt;): void ...@@ -1113,8 +1113,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);
...@@ -1148,8 +1148,8 @@ setPasteData(data: PasteData): Promise&lt;void&gt; ...@@ -1148,8 +1148,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) => {
...@@ -1175,13 +1175,13 @@ getPasteData( callback: AsyncCallback&lt;PasteData&gt;): void ...@@ -1175,13 +1175,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();
}); });
``` ```
...@@ -1203,9 +1203,9 @@ getPasteData(): Promise&lt;PasteData&gt; ...@@ -1203,9 +1203,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);
}) })
...@@ -1230,8 +1230,8 @@ on(type: 'update', callback: () =&gt;void ): void ...@@ -1230,8 +1230,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);
...@@ -1282,10 +1282,10 @@ hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1282,10 +1282,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}`);
}); });
``` ```
...@@ -1308,9 +1308,9 @@ hasPasteData(): Promise&lt;boolean&gt; ...@@ -1308,9 +1308,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}`);
}); });
``` ```
...@@ -1334,7 +1334,7 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -1334,7 +1334,7 @@ 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.');
...@@ -1362,6 +1362,6 @@ clear(): Promise&lt;void&gt; ...@@ -1362,6 +1362,6 @@ 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}`);
}); });
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册