clipboard.readText()
读取当前系统剪贴板文本。没有纯文本类型或用户取消时返回 null;存在的空文本返回空字符串。
Syntax
const text = await host.clipboard.readText(options?);
Parameters
options?: CallOptions:可选取消信号。
Return value
string | null。剪贴板没有纯文本或用户关闭平台提示时返回 null;空字符串是存在的空文本,不等于 null。
Examples
pasteButton.onclick = async () => {
const text = await host.clipboard.readText();
if (text !== null) editor.insert(text);
};
Errors
特有错误:denied、activation-required、cancelled、invalid-data、sink-too-small、limit-exceeded。读取来源为 external-resource,结果不得写入日志。取消先于读取提交点时不得取得内容;读取先提交则返回正常结果。
Requirements
- 能力:
host:clipboard.readText - 每次可信用户激活:必须
- 可取消:是;调用取消以
cancelled失败,用户关闭平台提示返回null - 信任档位:lime