Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
45d91f39
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看板
未验证
提交
45d91f39
编写于
10月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10878 [3.2beta3]修复剪贴板API参考中规范问题&属性/常量问题
Merge pull request !10878 from qimeng/OpenHarmony-3.2-Beta3
上级
9aa01131
c754ec3e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
114 addition
and
114 deletion
+114
-114
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
+114
-114
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-pasteboard.md
浏览文件 @
45d91f39
...
@@ -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<string>
...
@@ -472,11 +472,11 @@ convertToText(): Promise<string>
**示例:**
**示例:**
```
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<string>): void
...
@@ -498,13 +498,13 @@ convertToText(callback: AsyncCallback<string>): 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<string>
...
@@ -854,8 +854,8 @@ getMimeTypes(): Array<string>
**示例:**
**示例:**
```
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<void>): void
...
@@ -1113,8 +1113,8 @@ setPasteData(data: PasteData, callback: AsyncCallback<void>): 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<void>
...
@@ -1148,8 +1148,8 @@ setPasteData(data: PasteData): Promise<void>
**示例:**
**示例:**
```
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<PasteData>): void
...
@@ -1175,13 +1175,13 @@ getPasteData( callback: AsyncCallback<PasteData>): 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<PasteData>
...
@@ -1203,9 +1203,9 @@ getPasteData(): Promise<PasteData>
**示例:**
**示例:**
```
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: () =>void ): void
...
@@ -1230,8 +1230,8 @@ on(type: 'update', callback: () =>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
);
...
@@ -1258,7 +1258,7 @@ off(type: 'update', callback?: () =>void ): void
...
@@ -1258,7 +1258,7 @@ off(type: 'update', callback?: () =>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
);
```
```
...
@@ -1282,10 +1282,10 @@ hasPasteData(callback: AsyncCallback<boolean>): void
...
@@ -1282,10 +1282,10 @@ hasPasteData(callback: AsyncCallback<boolean>): 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<boolean>
...
@@ -1308,9 +1308,9 @@ hasPasteData(): Promise<boolean>
```
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
}
`
);
});
});
```
```
...
@@ -1333,9 +1333,9 @@ clear(callback: AsyncCallback<void>): void
...
@@ -1333,9 +1333,9 @@ clear(callback: AsyncCallback<void>): 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.
'
);
});
});
...
@@ -1361,7 +1361,7 @@ clear(): Promise<void>
...
@@ -1361,7 +1361,7 @@ clear(): Promise<void>
```
js
```
js
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录