-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
async function getClipboardContents() {
try {
const clipboardItems = await navigator.clipboard.read();
for (const clipboardItem of clipboardItems) {
for (const type of clipboardItem.types) {
const blob = await clipboardItem.getType(type);
if (blob.type.startsWith('image/')) {
// 处理图片
const imageUrl = URL.createObjectURL(blob);
console.log('图片 URL:', imageUrl);
} else if (blob.type.startsWith('text/')) {
// 处理文本
const text = await blob.text();
console.log('文本内容:', text);
} else {
// 处理其他类型数据
console.log('其他类型数据:', blob.type, blob);
}
}
}
} catch (err) {
console.error('读取剪贴板内容时出错:', err);
}
}可以很好的获取 来自word等内容,以便于做富文本解析等
Metadata
Metadata
Assignees
Labels
No labels