Skip to content

The swiss army knife of lossless video/audio editing

add copy report to clipboard button

Mikael Finstad6bb0a2aa13d1
diff --git a/src/App.jsx b/src/App.jsx
index 902471fe..9d9f811a 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -10,7 +10,6 @@ import { useDebounce } from 'use-debounce';
import filePathToUrl from 'file-url';
import i18n from 'i18next';
import { useTranslation } from 'react-i18next';
-import withReactContent from 'sweetalert2-react-content';
import Mousetrap from 'mousetrap';
import fromPairs from 'lodash/fromPairs';
@@ -72,8 +71,6 @@ const { dialog, app } = electron.remote;
const { focusWindow } = electron.remote.require('./electron');
-const ReactSwal = withReactContent(Swal);
-
const ffmpegExtractWindow = 60;
const calcShouldShowWaveform = (zoomedDuration) => (zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8);
diff --git a/src/HelpSheet.jsx b/src/HelpSheet.jsx
index f90b5d4e..1b79300d 100644
--- a/src/HelpSheet.jsx
+++ b/src/HelpSheet.jsx
@@ -1,14 +1,13 @@
import React, { memo } from 'react';
-import { FaClipboard, FaHandPointRight, FaHandPointLeft, FaStepBackward, FaStepForward } from 'react-icons/fa';
+import { FaHandPointRight, FaHandPointLeft, FaStepBackward, FaStepForward } from 'react-icons/fa';
import { useTranslation, Trans } from 'react-i18next';
import SetCutpointButton from './components/SetCutpointButton';
-import { toast } from './util';
+import CopyClipboardButton from './components/CopyClipboardButton';
import { primaryTextColor } from './colors';
import Sheet from './Sheet';
const electron = window.require('electron');
-const { clipboard } = electron;
const { githubLink } = electron.remote.require('./constants');
@@ -92,7 +91,7 @@ const HelpSheet = memo(({ visible, onTogglePress, ffmpegCommandLog, currentCutSe
{ffmpegCommandLog.reverse().map(({ command }, i) => (
// eslint-disable-next-line react/no-array-index-key
<div key={i} style={{ whiteSpace: 'pre', margin: '5px 0' }}>
- <FaClipboard style={{ cursor: 'pointer' }} title={t('Copy to clipboard')} onClick={() => { clipboard.writeText(command); toast.fire({ timer: 2000, icon: 'success', title: t('Copied to clipboard') }); }} /> {command}
+ <CopyClipboardButton text={command} /> {command}
</div>
))}
</div>
diff --git a/src/components/CopyClipboardButton.jsx b/src/components/CopyClipboardButton.jsx
new file mode 100644
index 00000000..4085157e
--- /dev/null
+++ b/src/components/CopyClipboardButton.jsx
@@ -0,0 +1,30 @@
+import React, { memo, useCallback } from 'react';
+import { FaClipboard } from 'react-icons/fa';
+import { useTranslation } from 'react-i18next';
+import { motion, useAnimation } from 'framer-motion';
+
+const electron = window.require('electron');
+const { clipboard } = electron;
+
+const CopyClipboardButton = memo(({ text, style }) => {
+ const { t } = useTranslation();
+
+ const animation = useAnimation();
+
+ const onClick = useCallback(() => {
+ clipboard.writeText(text);
+ animation.start({
+ scale: [1, 2, 1],
+ transition: { duration: 0.3 },
+ });
+ }, [animation, text]);
+
+ return (
+ <motion.div animate={animation} style={{ display: 'inline-block', cursor: 'pointer', ...style }}>
+ <FaClipboard title={t('Copy to clipboard')} onClick={onClick} />
+ </motion.div>
+
+ );
+});
+
+export default CopyClipboardButton;
diff --git a/src/reporting.jsx b/src/reporting.jsx
index e46f7014..12b82215 100644
--- a/src/reporting.jsx
+++ b/src/reporting.jsx
@@ -3,6 +3,7 @@ import Swal from 'sweetalert2';
import withReactContent from 'sweetalert2-react-content';
import i18n from 'i18next';
+import CopyClipboardButton from './components/CopyClipboardButton';
import { isStoreBuild, isMasBuild, isWindowsStoreBuild } from './util';
const electron = window.require('electron'); // eslint-disable-line
@@ -20,6 +21,26 @@ export function openSendReportDialog(err, state) {
const platform = os.platform();
const version = electron.remote.app.getVersion();
+ const text = `${err ? err.stack : 'No error'}\n\n${JSON.stringify({
+ err: err && {
+ code: err.code,
+ killed: err.killed,
+ failed: err.failed,
+ timedOut: err.timedOut,
+ isCanceled: err.isCanceled,
+ exitCode: err.exitCode,
+ signal: err.signal,
+ signalDescription: err.signalDescription,
+ },
+
+ state,
+
+ platform,
+ version,
+ isWindowsStoreBuild,
+ isMasBuild,
+ }, null, 2)}`;
+
ReactSwal.fire({
showCloseButton: true,
title: i18n.t('Send problem report'),
@@ -27,28 +48,10 @@ export function openSendReportDialog(err, state) {
<div style={{ textAlign: 'left', overflow: 'auto', maxHeight: 300, overflowY: 'auto' }}>
{reportInstructions}
- <p>Include the following text:</p>
+ <p>Include the following text: <CopyClipboardButton text={text} /></p>
<div style={{ fontWeight: 600, fontSize: 12, whiteSpace: 'pre-wrap' }} contentEditable suppressContentEditableWarning>
- {`${err ? err.stack : 'No error'}\n\n${JSON.stringify({
- err: err && {
- code: err.code,
- killed: err.killed,
- failed: err.failed,
- timedOut: err.timedOut,
- isCanceled: err.isCanceled,
- exitCode: err.exitCode,
- signal: err.signal,
- signalDescription: err.signalDescription,
- },
-
- state,
-
- platform,
- version,
- isWindowsStoreBuild,
- isMasBuild,
- }, null, 2)}`}
+ {text}
</div>
</div>
),