feat: added cut, copy, paste and show command palette functions in header (#5648)

This commit is contained in:
Ariel Leyva
2026-01-18 02:55:20 -05:00
committed by GitHub
parent 550a73b6ba
commit 785b7abb7b
3 changed files with 105 additions and 1 deletions

View File

@@ -51,6 +51,20 @@ export function copy(data: ClipboardArgs, opts?: ClipboardOpts) {
});
}
export function read() {
return new Promise<string>((resolve, reject) => {
if (
// Clipboard API requires secure context
window.isSecureContext &&
typeof navigator.clipboard !== "undefined"
) {
navigator.clipboard.readText().then(resolve).catch(reject);
} else {
reject();
}
});
}
function getPermission(name: string) {
return new Promise<void>((resolve, reject) => {
typeof navigator.permissions !== "undefined" &&