diff options
Diffstat (limited to 'src/content/repositories/ClipboardRepository.ts')
-rw-r--r-- | src/content/repositories/ClipboardRepository.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/content/repositories/ClipboardRepository.ts b/src/content/repositories/ClipboardRepository.ts index 8219835..a700543 100644 --- a/src/content/repositories/ClipboardRepository.ts +++ b/src/content/repositories/ClipboardRepository.ts @@ -6,39 +6,39 @@ export default interface ClipboardRepository { export class ClipboardRepositoryImpl { read(): string { - const textarea = window.document.createElement('textarea'); + const textarea = window.document.createElement("textarea"); window.document.body.append(textarea); - textarea.style.position = 'fixed'; - textarea.style.top = '-100px'; - textarea.contentEditable = 'true'; + textarea.style.position = "fixed"; + textarea.style.top = "-100px"; + textarea.contentEditable = "true"; textarea.focus(); - const ok = window.document.execCommand('paste'); + const ok = window.document.execCommand("paste"); const value = textarea.textContent!!; textarea.remove(); if (!ok) { - throw new Error('failed to access clipbaord'); + throw new Error("failed to access clipbaord"); } return value; } write(text: string): void { - const input = window.document.createElement('input'); + const input = window.document.createElement("input"); window.document.body.append(input); - input.style.position = 'fixed'; - input.style.top = '-100px'; + input.style.position = "fixed"; + input.style.top = "-100px"; input.value = text; input.select(); - const ok = window.document.execCommand('copy'); + const ok = window.document.execCommand("copy"); input.remove(); if (!ok) { - throw new Error('failed to access clipbaord'); + throw new Error("failed to access clipbaord"); } } } |