Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b8b3e12f
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b8b3e12f
编写于
10月 20, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10700 optimizing the markdown of pasteboard apis
Merge pull request !10700 from qimeng/master
上级
4c4984d1
140e2d2d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
137 addition
and
137 deletion
+137
-137
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
+137
-137
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
浏览文件 @
b8b3e12f
...
...
@@ -12,18 +12,18 @@
import
pasteboard
from
'
@ohos.pasteboard
'
;
```
##
属性
##
常量
**系统能力:**
SystemCapability.MiscServices.Pasteboard
| 名称 | 参数类型 |
可读 | 可写
| 说明 |
| -------- | -------- | -------- | -------- |
-------- |
| MAX_RECORD_NUM
<sup>
7+
</sup>
| number |
是 | 否
| 单个PasteData中所能包含的最大条目数。 |
| MIMETYPE_TEXT_HTML
<sup>
7+
</sup>
| string |
是 | 否
| HTML内容的MIME类型定义。 |
| MIMETYPE_TEXT_WANT
<sup>
7+
</sup>
| string |
是 | 否
| Want内容的MIME类型定义。 |
| MIMETYPE_TEXT_PLAIN
<sup>
7+
</sup>
| string |
是 | 否
| 纯文本内容的MIME类型定义。 |
| MIMETYPE_TEXT_URI
<sup>
7+
</sup>
| string |
是 | 否
| URI内容的MIME类型定义。 |
| MIMETYPE_PIXELMAP
<sup>
9+
</sup>
| string |
是 | 否
| PixelMap内容的MIME类型定义。 |
| 名称 | 参数类型 |
值
| 说明 |
| -------- | -------- | -------- | -------- |
| MAX_RECORD_NUM
<sup>
7+
</sup>
| number |
512
| 单个PasteData中所能包含的最大条目数。 |
| MIMETYPE_TEXT_HTML
<sup>
7+
</sup>
| string |
'text/html'
| HTML内容的MIME类型定义。 |
| MIMETYPE_TEXT_WANT
<sup>
7+
</sup>
| string |
'text/want'
| Want内容的MIME类型定义。 |
| MIMETYPE_TEXT_PLAIN
<sup>
7+
</sup>
| string |
'text/plain'
| 纯文本内容的MIME类型定义。 |
| MIMETYPE_TEXT_URI
<sup>
7+
</sup>
| string |
'text/uri'
| URI内容的MIME类型定义。 |
| MIMETYPE_PIXELMAP
<sup>
9+
</sup>
| string |
'pixelMap'
| PixelMap内容的MIME类型定义。 |
## ValueType<sup>9+</sup>
...
...
@@ -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.createRecord<sup>9+</sup>
...
...
@@ -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
();
```
## ShareOption<sup>9+</sup>
...
...
@@ -152,8 +152,8 @@ createHtmlData(htmlText: string): PasteData
**示例:**
```
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>
"
;
var
pasteData
=
pasteboard
.
createHtmlData
(
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>
"
;
let
pasteData
=
pasteboard
.
createHtmlData
(
html
);
```
## pasteboard.createWantData<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -215,7 +215,7 @@ createPlainTextData(text: string): PasteData
**示例:**
```
js
var
pasteData
=
pasteboard
.
createPlainTextData
(
"
content
"
);
let
pasteData
=
pasteboard
.
createPlainTextData
(
'
content
'
);
```
## pasteboard.createUriData<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -272,8 +272,8 @@ createHtmlTextRecord(htmlText: string): PasteDataRecord
**示例:**
```
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>
"
;
var
record
=
pasteboard
.
createHtmlTextRecord
(
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>
"
;
let
record
=
pasteboard
.
createHtmlTextRecord
(
html
);
```
## pasteboard.createWantRecord<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -335,7 +335,7 @@ createPlainTextRecord(text: string): PasteDataRecord
**示例:**
```
js
var
record
=
pasteboard
.
createPlainTextRecord
(
"
hello
"
);
let
record
=
pasteboard
.
createPlainTextRecord
(
'
hello
'
);
```
## pasteboard.createUriRecord<sup>(deprecated)</sup>
...
...
@@ -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
();
```
### getPrimaryHtml<sup>7+</sup>
...
...
@@ -557,9 +557,9 @@ getPrimaryHtml(): string
**示例:**
```
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>
"
;
var
pasteData
=
pasteboard
.
createHtmlData
(
html
);
var
htmlText
=
pasteData
.
getPrimaryHtml
();
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>
"
;
let
pasteData
=
pasteboard
.
createHtmlData
(
html
);
let
htmlText
=
pasteData
.
getPrimaryHtml
();
```
### getPrimaryWant<sup>7+</sup>
...
...
@@ -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
();
```
### getPrimaryUri<sup>7+</sup>
...
...
@@ -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
();
```
### getPrimaryPixelMap<sup>9+</sup>
...
...
@@ -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
();
})
;
```
### addRecord<sup>7+</sup>
...
...
@@ -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
=
"
<!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
pasteData
=
pasteboard
.
createUriData
(
'
dataability:///com.example.myapplication1/user.txt
'
);
let
textRecord
=
pasteboard
.
createPlainTextRecord
(
'
hello
'
);
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>
"
;
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
();
```
### getPrimaryMimeType<sup>7+</sup>
...
...
@@ -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
();
```
### getProperty<sup>7+</sup>
...
...
@@ -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
();
```
### setProperty<sup>9+</sup>
...
...
@@ -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
);
```
### getRecordCount<sup>7+</sup>
...
...
@@ -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
();
```
### getTag<sup>7+</sup>
...
...
@@ -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
();
```
### hasType<sup>9+</sup>
...
...
@@ -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
);
```
### removeRecord<sup>9+</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -967,8 +967,8 @@ addHtmlRecord(htmlText: string): void
**示例:**
```
js
var
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
pasteData
=
pasteboard
.
createPlainTextData
(
'
hello
'
);
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
);
```
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -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<sup>(deprecated)</sup>
...
...
@@ -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')<sup>7+</sup>
...
...
@@ -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.
'
);
});
...
...
@@ -1277,8 +1277,8 @@ clearData(): Promise<void>
```
js
systemPasteboard
.
clearData
().
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in clearing the pasteboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to clear the pasteboard. Cause:
'
+
JSON
.
stringify
(
err
)
);
}).
catch
((
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
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录