copyableInput no longer uses electron clipboard

This commit is contained in:
jessop 2019-08-22 21:32:09 -04:00 committed by Sean Yesmunt
parent d6748b0627
commit 82d57eb574
2 changed files with 22 additions and 4 deletions

View file

@ -1,7 +1,6 @@
// @flow
import * as ICONS from 'constants/icons';
import * as React from 'react';
import { clipboard } from 'electron';
import { FormField } from 'component/common/form';
import Button from 'component/button';
@ -18,10 +17,19 @@ export default class CopyableText extends React.PureComponent<Props> {
this.input = React.createRef();
(this: any).onFocus = this.onFocus.bind(this);
(this: any).copyToClipboard = this.copyToClipboard.bind(this);
}
input: { current: React.ElementRef<any> };
copyToClipboard() {
const topRef = this.input.current;
if (topRef && topRef.input && topRef.input.current) {
topRef.input.current.select();
}
document.execCommand('copy');
}
onFocus() {
// We have to go a layer deep since the input is inside the form component
const topRef = this.input.current;
@ -47,7 +55,7 @@ export default class CopyableText extends React.PureComponent<Props> {
button="inverse"
icon={ICONS.COPY}
onClick={() => {
clipboard.writeText(copyable);
this.copyToClipboard();
doToast({
message: snackMessage || __('Text copied'),
});

View file

@ -638,5 +638,15 @@
"For more details on backing up and best practices": "For more details on backing up and best practices",
"File Size": "File Size",
"You deposited 1 LBC as a support!": "You deposited 1 LBC as a support!",
"Refreshed!": "Refreshed!"
}
"Refreshed!": "Refreshed!",
"Starting...": "Starting...",
"Spin Spin Sugar": "Spin Spin Sugar",
"You're not following any channels.": "You're not following any channels.",
"Look what's trending for everyone": "Look what's trending for everyone",
"or": "or",
"Discover some channels!": "Discover some channels!",
"Trending": "Trending",
"Top": "Top",
"New": "New",
"Loading": "Loading"
}