From 1e6c00195e7e720d6b1907c664251e8951738a79 Mon Sep 17 00:00:00 2001 From: qimeng Date: Mon, 17 Oct 2022 17:18:51 +0800 Subject: [PATCH] Signed-off-by: qimeng Changes to be committed: modified: zh-cn/application-dev/reference/apis/js-apis-pasteboard.md --- .../reference/apis/js-apis-pasteboard.md | 270 +++++++++--------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 62b255c8ac..038f9160d5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -16,14 +16,14 @@ import pasteboard from '@ohos.pasteboard'; **系统能力:** SystemCapability.MiscServices.Pasteboard -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| MAX_RECORD_NUM7+ | number | 是 | 否 | 单个PasteData中所能包含的最大条目数。 | -| MIMETYPE_TEXT_HTML7+ | string | 是 | 否 | HTML内容的MIME类型定义。 | -| MIMETYPE_TEXT_WANT7+ | string | 是 | 否 | Want内容的MIME类型定义。 | -| MIMETYPE_TEXT_PLAIN7+ | string | 是 | 否 | 纯文本内容的MIME类型定义。 | -| MIMETYPE_TEXT_URI7+ | string | 是 | 否 | URI内容的MIME类型定义。 | -| MIMETYPE_PIXELMAP9+ | string | 是 | 否 | PixelMap内容的MIME类型定义。 | +| 名称 | 参数类型 | 值 | 说明 | +| -------- | -------- | -------- | -------- | +| MAX_RECORD_NUM7+ | number | 512 | 单个PasteData中所能包含的最大条目数。 | +| MIMETYPE_TEXT_HTML7+ | string | text/html | HTML内容的MIME类型定义。 | +| MIMETYPE_TEXT_WANT7+ | string | text/want | Want内容的MIME类型定义。 | +| MIMETYPE_TEXT_PLAIN7+ | string | text/plain | 纯文本内容的MIME类型定义。 | +| MIMETYPE_TEXT_URI7+ | string | text/uri | URI内容的MIME类型定义。 | +| MIMETYPE_PIXELMAP9+ | string | pixelMap | PixelMap内容的MIME类型定义。 | ## ValueType9+ @@ -62,8 +62,8 @@ createData(mimeType: string, value: ValueType): PasteData **示例:** ```js - var dataXml = 'aStringValueType'; - var pasteData = pasteboard.createData('app/xml', dataXml); + let dataXml = new ArrayBuffer(256); + let pasteData = pasteboard.createData('app/xml', dataXml); ``` ## pasteboard.createRecord9+ @@ -90,8 +90,8 @@ createRecord(mimeType: string, value: ValueType):PasteDataRecord; **示例:** ```js - var dataXml = 'aStringValueType'; - var pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); + let dataXml = new ArrayBuffer(256); + let pasteDataRecord = pasteboard.createRecord('app/xml', dataXml); ``` ## pasteboard.getSystemPasteboard @@ -111,7 +111,7 @@ getSystemPasteboard(): SystemPasteboard **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +let systemPasteboard = pasteboard.getSystemPasteboard(); ``` ## ShareOption9+ @@ -152,8 +152,8 @@ createHtmlData(htmlText: string): PasteData **示例:** ```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); +let html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +let pasteData = pasteboard.createHtmlData(html); ``` ## pasteboard.createWantData(deprecated) @@ -182,11 +182,11 @@ createWantData(want: Want): PasteData **示例:** ```js -var object = { +let object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" }; -var pasteData = pasteboard.createWantData(object); +let pasteData = pasteboard.createWantData(object); ``` ## pasteboard.createPlainTextData(deprecated) @@ -215,7 +215,7 @@ createPlainTextData(text: string): PasteData **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); +let pasteData = pasteboard.createPlainTextData('content'); ``` ## pasteboard.createUriData(deprecated) @@ -244,7 +244,7 @@ createUriData(uri: string): PasteData **示例:** ```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); +let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); ``` ## pasteboard.createHtmlTextRecord(deprecated) @@ -272,8 +272,8 @@ createHtmlTextRecord(htmlText: string): PasteDataRecord **示例:** ```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var record = pasteboard.createHtmlTextRecord(html); +let html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +let record = pasteboard.createHtmlTextRecord(html); ``` ## pasteboard.createWantRecord(deprecated) @@ -302,11 +302,11 @@ createWantRecord(want: Want): PasteDataRecord **示例:** ```js -var object = { +let object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" }; -var record = pasteboard.createWantRecord(object); +let record = pasteboard.createWantRecord(object); ``` ## pasteboard.createPlainTextRecord(deprecated) @@ -335,7 +335,7 @@ createPlainTextRecord(text: string): PasteDataRecord **示例:** ```js -var record = pasteboard.createPlainTextRecord("hello"); +let record = pasteboard.createPlainTextRecord('hello'); ``` ## pasteboard.createUriRecord(deprecated) @@ -364,7 +364,7 @@ createUriRecord(uri: string): PasteDataRecord **示例:** ```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<string>): void **示例:** ```js -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); -record.convertToTextV9((err, data) => { - if (err) { - console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); +let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt'); +record.convertToTextV9((err, data) => { + if (err) { + console.error('Failed to convert to text. Cause: ${err.message}'); + return; + } + console.info('Succeeded in converting to text. Data: ${data}'); }); ``` @@ -445,11 +445,11 @@ convertToTextV9(): Promise<string> **示例:** ```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) => { - console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); + console.info('Succeeded in converting to text. Data: ${data}'); }).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<string>): void **示例:** ```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) => { if (err) { - console.error('Failed to convert to text. Cause: ' + JSON.stringify(err)); + console.error('Failed to convert to text. Cause: ${err.message}'); 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<string> **示例:** ```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) => { - console.info('Succeeded in converting to text. Data: ' + JSON.stringify(data)); + console.info('Succeeded in converting to text. Data: ${data}'); }).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 **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var plainText = pasteData.getPrimaryText(); +let pasteData = pasteboard.createPlainTextData('hello'); +let plainText = pasteData.getPrimaryText(); ``` ### getPrimaryHtml7+ @@ -557,9 +557,9 @@ getPrimaryHtml(): string **示例:** ```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); -var htmlText = pasteData.getPrimaryHtml(); +let html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +let pasteData = pasteboard.createHtmlData(html); +let htmlText = pasteData.getPrimaryHtml(); ``` ### getPrimaryWant7+ @@ -579,12 +579,12 @@ getPrimaryWant(): Want **示例:** ```js -var object = { - bundleName: "com.example.aafwk.test", +let object = { + bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" }; -var pasteData = pasteboard.createWantData(object); -var want = pasteData.getPrimaryWant(); +let pasteData = pasteboard.createWantData(object); +let want = pasteData.getPrimaryWant(); ``` ### getPrimaryUri7+ @@ -604,8 +604,8 @@ getPrimaryUri(): string **示例:** ```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); -var uri = pasteData.getPrimaryUri(); +let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); +let uri = pasteData.getPrimaryUri(); ``` ### getPrimaryPixelMap9+ @@ -627,18 +627,18 @@ getPrimaryPixelMap(): image.PixelMap ```js import image from '@ohos.multimedia.image'; -var buffer = new ArrayBuffer(128) -var opt = { +let buffer = new ArrayBuffer(128); +let opt = { size: { height: 3, width: 5 }, pixelFormat: 3, editable: true, alphaType: 1, scaleMode: 1 -} +}; image.createPixelMap(buffer, opt).then((pixelMap) => { - var pasteData = pasteboard.createPixelMapData(pixelMap); - var pixelMap = pasteData.getPrimaryPixelMap(); -}) + let pasteData = pasteboard.createPixelMapData(pixelMap); + let pixelMap = pasteData.getPrimaryPixelMap(); +}); ``` ### addRecord7+ @@ -660,10 +660,10 @@ addRecord(record: PasteDataRecord): void **示例:** ```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); -var textRecord = pasteboard.createPlainTextRecord("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var htmlRecord = pasteboard.createHtmlTextRecord(html); +let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); +let textRecord = pasteboard.createPlainTextRecord('hello'); +let html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +let htmlRecord = pasteboard.createHtmlTextRecord(html); pasteData.addRecord(textRecord); pasteData.addRecord(htmlRecord); ``` @@ -694,8 +694,8 @@ addRecord(mimeType: string, value: ValueType): void **示例:** ```js - var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1/user.txt"); - var dataXml = 'aStringValueType'; + let pasteData = pasteboard.createUriData('dataability:///com.example.myapplication1/user.txt'); + let dataXml = new ArrayBuffer(256); pasteData.addRecord('app/xml', dataXml); ``` @@ -716,8 +716,8 @@ getMimeTypes(): Array<string> **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var types = pasteData.getMimeTypes(); +let pasteData = pasteboard.createPlainTextData('hello'); +let types = pasteData.getMimeTypes(); ``` ### getPrimaryMimeType7+ @@ -737,8 +737,8 @@ getPrimaryMimeType(): string **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var type = pasteData.getPrimaryMimeType(); +let pasteData = pasteboard.createPlainTextData('hello'); +let type = pasteData.getPrimaryMimeType(); ``` ### getProperty7+ @@ -758,8 +758,8 @@ getProperty(): PasteDataProperty **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var property = pasteData.getProperty(); +let pasteData = pasteboard.createPlainTextData('hello'); +let property = pasteData.getProperty(); ``` ### setProperty9+ @@ -779,7 +779,7 @@ setProperty(property: PasteDataProperty): void **示例:** ```js -var pasteData = pasteboard.createHtmlData('application/xml'); +let pasteData = pasteboard.createHtmlData('application/xml'); let prop = pasteData.getProperty(); prop.shareOption = pasteboard.ShareOption.InApp; pasteData.setProperty(prop); @@ -815,8 +815,8 @@ getRecord(index: number): PasteDataRecord **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteData.getRecord(0); +let pasteData = pasteboard.createPlainTextData('hello'); +let record = pasteData.getRecord(0); ``` ### getRecordCount7+ @@ -836,8 +836,8 @@ getRecordCount(): number **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var count = pasteData.getRecordCount(); +let pasteData = pasteboard.createPlainTextData('hello'); +let count = pasteData.getRecordCount(); ``` ### getTag7+ @@ -857,8 +857,8 @@ getTag(): string **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var tag = pasteData.getTag(); +let pasteData = pasteboard.createPlainTextData('hello'); +let tag = pasteData.getTag(); ``` ### hasType9+ @@ -884,8 +884,8 @@ hasType(mimeType: string): boolean **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN); +let pasteData = pasteboard.createPlainTextData('hello'); +let hasType = pasteData.hasType(pasteboard.MIMETYPE_TEXT_PLAIN); ``` ### removeRecord9+ @@ -912,7 +912,7 @@ removeRecord(index: number): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); +let pasteData = pasteboard.createPlainTextData('hello'); pasteData.removeRecord(0); ``` @@ -941,8 +941,8 @@ replaceRecord(index: number, record: PasteDataRecord): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); +let pasteData = pasteboard.createPlainTextData('hello'); +let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt'); pasteData.replaceRecord(0, record); ``` ### addHtmlRecord(deprecated) @@ -967,8 +967,8 @@ addHtmlRecord(htmlText: string): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; +let pasteData = pasteboard.createPlainTextData('hello'); +let html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; pasteData.addHtmlRecord(html); ``` @@ -994,8 +994,8 @@ addWantRecord(want: Want): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var object = { +let pasteData = pasteboard.createPlainTextData('hello'); +let object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" }; @@ -1024,8 +1024,8 @@ addTextRecord(text: string): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addTextRecord("good"); +let pasteData = pasteboard.createPlainTextData('hello'); +pasteData.addTextRecord('good'); ``` ### addUriRecord(deprecated) @@ -1050,8 +1050,8 @@ addUriRecord(uri: string): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addUriRecord("dataability:///com.example.myapplication1/user.txt"); +let pasteData = pasteboard.createPlainTextData('hello'); +pasteData.addUriRecord('dataability:///com.example.myapplication1/user.txt'); ``` ### getRecordAt(deprecated) @@ -1079,8 +1079,8 @@ getRecordAt(index: number): PasteDataRecord **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteData.getRecordAt(0); +let pasteData = pasteboard.createPlainTextData('hello'); +let record = pasteData.getRecordAt(0); ``` ### hasMimeType(deprecated) @@ -1109,8 +1109,8 @@ hasMimeType(mimeType: string): boolean **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); +let pasteData = pasteboard.createPlainTextData('hello'); +let hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); ``` ### removeRecordAt(deprecated) @@ -1138,8 +1138,8 @@ removeRecordAt(index: number): boolean **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var isRemove = pasteData.removeRecordAt(0); +let pasteData = pasteboard.createPlainTextData('hello'); +let isRemove = pasteData.removeRecordAt(0); ``` ### replaceRecordAt(deprecated) @@ -1168,9 +1168,9 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean **示例:** ```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1/user.txt"); -var isReplace = pasteData.replaceRecordAt(0, record); +let pasteData = pasteboard.createPlainTextData('hello'); +let record = pasteboard.createUriRecord('dataability:///com.example.myapplication1/user.txt'); +let isReplace = pasteData.replaceRecordAt(0, record); ``` ## SystemPasteboard @@ -1180,7 +1180,7 @@ var isReplace = pasteData.replaceRecordAt(0, record); 在调用SystemPasteboard的接口前,需要先通过[getSystemPasteboard](#pasteboardgetsystempasteboard)获取系统剪贴板。 ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +let systemPasteboard = pasteboard.getSystemPasteboard(); ``` ### on('update')7+ @@ -1201,8 +1201,8 @@ on(type: 'update', callback: () =>void ): void **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -var listener = () => { +let systemPasteboard = pasteboard.getSystemPasteboard(); +let listener = () => { console.info('The system pasteboard has changed.'); }; systemPasteboard.on('update', listener); @@ -1228,7 +1228,7 @@ off(type: 'update', callback?: () =>void ): void ```js let listener = () => { console.info('The system pasteboard has changed.'); -}; +}; systemPasteboard.off('update', listener); ``` @@ -1250,9 +1250,9 @@ clearData(callback: AsyncCallback<void>): void ```js systemPasteboard.clearData((err, data) => { - if (err) { - console.error('Failed to clear the pasteboard. Cause: ' + JSON.stringify(err)); - return; + if (err) { + console.error('Failed to clear the pasteboard. Cause: ${err.message}'); + return; } console.info('Succeeded in clearing the pasteboard.'); }); @@ -1278,7 +1278,7 @@ clearData(): Promise<void> systemPasteboard.clearData().then((data) => { console.info('Succeeded in clearing the pasteboard.'); }).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<void>): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); +let pasteData = pasteboard.createPlainTextData('content'); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setData(pasteData, (err, data) => { if (err) { console.error('Failed to set PasteData. Cause: ' + err.message); @@ -1350,8 +1350,8 @@ setData(data: PasteData): Promise<void> **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); +let pasteData = pasteboard.createPlainTextData('content'); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setData(pasteData).then((data) => { console.info('Succeeded in setting PasteData.'); }).catch((err) => { @@ -1383,13 +1383,13 @@ getData( callback: AsyncCallback<PasteData>): void **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getData((err, pasteData) => { if (err) { console.error('Failed to get PasteData. Cause: ' + err.message); return; } - var text = pasteData.getPrimaryText(); + let text = pasteData.getPrimaryText(); }); ``` @@ -1417,9 +1417,9 @@ getData(): Promise<PasteData> **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getData().then((pasteData) => { - var text = pasteData.getPrimaryText(); + let text = pasteData.getPrimaryText(); }).catch((err) => { console.error('Failed to get PasteData. Cause: ' + err.message); }) @@ -1444,10 +1444,10 @@ hasData(callback: AsyncCallback<boolean>): void ```js systemPasteboard.hasData((err, data) => { if (err) { - console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); + console.error('Failed to check the PasteData. Cause: ${err.message}'); 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<boolean> ```js 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) => { - 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<void>): void ```js systemPasteboard.clear((err, data) => { if (err) { - console.error('Failed to clear the PasteData. Cause: ' + JSON.stringify(err)); - return; + console.error('Failed to clear the PasteData. Cause: ${err.message}'); + return; } console.info('Succeeded in clearing the PasteData.'); }); @@ -1527,7 +1527,7 @@ clear(): Promise<void> systemPasteboard.clear().then((data) => { console.info('Succeeded in clearing the PasteData.'); }).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<PasteData>): void **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.getPasteData((err, pasteData) => { +let systemPasteboard = pasteboard.getSystemPasteboard(); +systemPasteboard.getPasteData((err, pasteData) => { if (err) { console.error('Failed to get PasteData. Cause: ' + err.message); return; } - var text = pasteData.getPrimaryText(); + let text = pasteData.getPrimaryText(); }); ``` @@ -1581,9 +1581,9 @@ getPasteData(): Promise<PasteData> **示例:** ```js -var systemPasteboard = pasteboard.getSystemPasteboard(); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getPasteData().then((pasteData) => { - var text = pasteData.getPrimaryText(); + let text = pasteData.getPrimaryText(); }).catch((err) => { console.error('Failed to get PasteData. Cause: ' + err.message); }) @@ -1611,10 +1611,10 @@ hasPasteData(callback: AsyncCallback<boolean>): void ```js systemPasteboard.hasPasteData((err, data) => { if (err) { - console.error('Failed to check the PasteData. Cause: ' + JSON.stringify(err)); + console.error('Failed to check the PasteData. Cause: ${err.message}'); 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<boolean> ```js 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) => { - 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<void>): void **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); +let pasteData = pasteboard.createPlainTextData('content'); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setPasteData(pasteData, (err, data) => { if (err) { console.error('Failed to set PasteData. Cause: ' + err.message); @@ -1702,8 +1702,8 @@ setPasteData(data: PasteData): Promise<void> **示例:** ```js -var pasteData = pasteboard.createPlainTextData("content"); -var systemPasteboard = pasteboard.getSystemPasteboard(); +let pasteData = pasteboard.createPlainTextData('content'); +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setPasteData(pasteData).then((data) => { console.info('Succeeded in setting PasteData.'); }).catch((err) => { -- GitLab