Avoid using electron directly for writing to clipboard
Summary: Similarly to previous stack, remove the need to import Electron to write things to clipboard. Introduced linter to prevent future use. Reviewed By: timur-valiev Differential Revision: D29661777 fbshipit-source-id: 7bc67ede40b65c5f232b69128f3a423e232ddc1b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5dbd3bd414
commit
9b9f5d15a1
@@ -22,7 +22,7 @@ import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
import {VariableSizeList as List} from 'react-window';
|
||||
import {clipboard, MenuItemConstructorOptions} from 'electron';
|
||||
import {MenuItemConstructorOptions} from 'electron';
|
||||
import TableHead from './TableHead';
|
||||
import TableRow from './TableRow';
|
||||
import ContextMenu from '../ContextMenu';
|
||||
@@ -33,6 +33,7 @@ import {debounce} from 'lodash';
|
||||
import {DEFAULT_ROW_HEIGHT} from './types';
|
||||
import textContent from '../../../utils/textContent';
|
||||
import {notNull} from '../../../utils/typeUtils';
|
||||
import {getFlipperLib} from 'flipper-plugin';
|
||||
|
||||
const EMPTY_OBJECT = {};
|
||||
Object.freeze(EMPTY_OBJECT);
|
||||
@@ -319,7 +320,7 @@ export class ManagedTable extends React.Component<
|
||||
};
|
||||
|
||||
onCopy = (withHeader: boolean) => {
|
||||
clipboard.writeText(
|
||||
getFlipperLib().writeTextToClipboard(
|
||||
[
|
||||
...(withHeader ? [this.getHeaderText()] : []),
|
||||
this.getSelectedText(),
|
||||
@@ -520,7 +521,7 @@ export class ManagedTable extends React.Component<
|
||||
|
||||
onCopyCell = (rowId: string, index: number) => {
|
||||
const cellText = this.getTextContentOfRow(rowId)[index];
|
||||
clipboard.writeText(cellText);
|
||||
getFlipperLib().writeTextToClipboard(cellText);
|
||||
};
|
||||
|
||||
buildContextMenuItems: () => Array<MenuItemConstructorOptions> = () => {
|
||||
|
||||
Reference in New Issue
Block a user