Skip to content

clipboard

NPM version

Platform Support

Platform Support

Platform Support

Platform Support

介绍:

剪切板插件

Reference

Method

  • read

    读取剪切板

ts
import { 
clipboardPlugin
} from "@plaoc/plugins";
const
res
= await
clipboardPlugin
.
read
();
  • write

    写入剪切板

根据规范,区分文本,图片,链接,都为字符串类型,另外android可传递label

ts
import { 
clipboardPlugin
, ClipboardWriteOptions } from "@plaoc/plugins";
await
clipboardPlugin
.
write
({
string
: "test" });

Parameter

  • ClipboardWriteOptions

    剪切板写入参数

ts
import { ClipboardWriteOptions } from "@plaoc/plugins";

const 
options
: ClipboardWriteOptions = {
string
: "",
image
: "",
url
: "",
label
: "" /**android only */,
};

Usage Plugins

vue
<script setup lang="ts">
import { 
clipboardPlugin
} from "@plaoc/plugins";
async function
read
() {
await
clipboardPlugin
.
read
();
} async function
write
() {
await
clipboardPlugin
.
write
({
string
: "hi" });
} </script>

Usage WebComponent

vue
<script setup lang="ts">
import { 
onMounted
,
ref
} from "vue";
import {
HTMLDwebClipboardElement
} from "@plaoc/plugins";
const
$clipboardPlugin
=
ref
<
HTMLDwebClipboardElement
>();
let
clipboard
:
HTMLDwebClipboardElement
;
onMounted
(async () => {
clipboard
=
$clipboardPlugin
.
value
!;
}); async function
read
() {
await
clipboard
.
read
();
} async function
write
() {
await
clipboard
.
write
({
string
: "usage" });
} </script> <template> <
dweb-clipboard
ref
="
$clipboardPlugin
"></
dweb-clipboard
>
</template>

基于 MIT 许可发布