Use library to handle copying to clipboard (#4989)

* Use library to handle copying

* Typo
This commit is contained in:
Nicolas Mowen 2023-01-10 05:23:04 -07:00 committed by GitHub
parent d49359e26a
commit 581c2591ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,7 @@
"dependencies": {
"@cycjimmy/jsmpeg-player": "^6.0.5",
"axios": "^1.2.2",
"copy-to-clipboard": "3.3.3",
"date-fns": "^2.29.3",
"idb-keyval": "^6.2.0",
"immer": "^9.0.16",

View File

@ -8,6 +8,7 @@ import { useEffect, useState } from 'preact/hooks';
import Button from '../components/Button';
import { editor, Uri } from 'monaco-editor';
import { setDiagnosticsOptions } from 'monaco-yaml';
import copy from 'copy-to-clipboard';
export default function Config() {
const apiHost = useApiHost();
@ -40,7 +41,7 @@ export default function Config() {
};
const handleCopyConfig = async () => {
await window.navigator.clipboard.writeText(window.editor.getValue());
copy(window.editor.getValue());
};
useEffect(() => {

View File

@ -9,6 +9,7 @@ import axios from 'axios';
import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table';
import { useState } from 'preact/hooks';
import Dialog from '../components/Dialog';
import copy from 'copy-to-clipboard';
const emptyObject = Object.freeze({});
@ -54,7 +55,7 @@ export default function System() {
};
const onCopyFfprobe = async () => {
await window.navigator.clipboard.writeText(JSON.stringify(state.ffprobe, null, 2));
copy(JSON.stringify(state.ffprobe, null, 2));
setState({ ...state, ffprobe: '', showFfprobe: false });
};
@ -73,7 +74,7 @@ export default function System() {
};
const onCopyVainfo = async () => {
await window.navigator.clipboard.writeText(JSON.stringify(state.vaifp, null, 2));
copy(JSON.stringify(state.vainfo, null, 2));
setState({ ...state, vainfo: '', showVainfo: false });
};