add a context menu to copy URI
Summary: It's handy to copy images URI to paste it in other tools Reviewed By: mweststrate Differential Revision: D20221861 fbshipit-source-id: 09074b434d5c1277bb83daa7846b885717c5ee8d
This commit is contained in:
committed by
Facebook Github Bot
parent
3ddd1c14f2
commit
2d9d0314b9
@@ -11,6 +11,7 @@ import {ImageData} from './api';
|
|||||||
import {ImageEventWithId} from './index';
|
import {ImageEventWithId} from './index';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
|
ContextMenu,
|
||||||
DataDescription,
|
DataDescription,
|
||||||
Text,
|
Text,
|
||||||
Panel,
|
Panel,
|
||||||
@@ -21,6 +22,7 @@ import {
|
|||||||
styled,
|
styled,
|
||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {clipboard, MenuItemConstructorOptions} from 'electron';
|
||||||
|
|
||||||
type ImagesSidebarProps = {
|
type ImagesSidebarProps = {
|
||||||
image: ImageData;
|
image: ImageData;
|
||||||
@@ -59,6 +61,14 @@ export default class ImagesSidebar extends Component<
|
|||||||
if (!this.props.image.uri) {
|
if (!this.props.image.uri) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contextMenuItems: MenuItemConstructorOptions[] = [
|
||||||
|
{
|
||||||
|
label: 'Copy URI',
|
||||||
|
click: () => clipboard.writeText(this.props.image.uri!),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel heading="Sources" floating={false}>
|
<Panel heading="Sources" floating={false}>
|
||||||
<FlexRow>
|
<FlexRow>
|
||||||
@@ -69,11 +79,13 @@ export default class ImagesSidebar extends Component<
|
|||||||
<span key="sep">: </span>
|
<span key="sep">: </span>
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
<WordBreakFlexColumn>
|
<WordBreakFlexColumn>
|
||||||
|
<ContextMenu component="span" items={contextMenuItems}>
|
||||||
<DataDescription
|
<DataDescription
|
||||||
type="string"
|
type="string"
|
||||||
value={this.props.image.uri}
|
value={this.props.image.uri}
|
||||||
setValue={null}
|
setValue={null}
|
||||||
/>
|
/>
|
||||||
|
</ContextMenu>
|
||||||
</WordBreakFlexColumn>
|
</WordBreakFlexColumn>
|
||||||
</FlexRow>
|
</FlexRow>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
Reference in New Issue
Block a user