clipboard
intro:
clipboard plugin
Reference
Method
read
read clipboard
ts
import { clipboardPlugin } from "@plaoc/plugins";
const res = await clipboardPlugin.read();
write
write to clipboard
According to the specification, text, images, and links are all of string type. In addition, android
can pass label
.
ts
import { clipboardPlugin } from "@plaoc/plugins";
await clipboardPlugin.write({ string: "test" });
Parameter
ClipboardWriteOptions
Clipboard writing parameters
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>