Copy/Paste implementation

Summary: ^

Reviewed By: aigoncharov

Differential Revision: D46515194

fbshipit-source-id: 0ee6931569d5248d5643b391683e230e0c095e41
This commit is contained in:
Lorenzo Blasa
2023-06-07 06:04:46 -07:00
committed by Facebook GitHub Bot
parent b9322247e6
commit 2815ba0fb8
5 changed files with 10 additions and 16 deletions

View File

@@ -63,7 +63,7 @@ export async function initializeElectron(
processId: electronProcess.pid, processId: electronProcess.pid,
isProduction, isProduction,
readTextFromClipboard() { readTextFromClipboard() {
return clipboard.readText(); return Promise.resolve(clipboard.readText());
}, },
writeTextToClipboard(text: string) { writeTextToClipboard(text: string) {
clipboard.writeText(text); clipboard.writeText(text);

View File

@@ -95,7 +95,7 @@ type ChildProcessEvents = {
* Utilities provided by the render host, e.g. Electron, the Browser, etc * Utilities provided by the render host, e.g. Electron, the Browser, etc
*/ */
export interface RenderHost { export interface RenderHost {
readTextFromClipboard(): string | undefined; readTextFromClipboard(): Promise<string> | undefined;
writeTextToClipboard(text: string): void; writeTextToClipboard(text: string): void;
/** /**
* @deprecated * @deprecated

View File

@@ -16,12 +16,9 @@ export function initializeRenderHost(
) { ) {
globalThis.FlipperRenderHostInstance = { globalThis.FlipperRenderHostInstance = {
readTextFromClipboard() { readTextFromClipboard() {
// TODO:
return undefined; return undefined;
}, },
writeTextToClipboard(_text: string) { writeTextToClipboard(_text: string) {},
// TODO:
},
async importFile() { async importFile() {
throw new Error('Not implemented'); throw new Error('Not implemented');
}, },
@@ -46,9 +43,7 @@ export function initializeRenderHost(
shouldUseDarkColors() { shouldUseDarkColors() {
return false; return false;
}, },
restartFlipper() { restartFlipper() {},
// TODO:
},
serverConfig: flipperServerConfig, serverConfig: flipperServerConfig,
GK(gatekeeper) { GK(gatekeeper) {
return flipperServerConfig.gatekeepers[gatekeeper] ?? false; return flipperServerConfig.gatekeepers[gatekeeper] ?? false;

View File

@@ -35,12 +35,11 @@ export function initializeRenderHost(
flipperServerConfig: FlipperServerConfig, flipperServerConfig: FlipperServerConfig,
) { ) {
FlipperRenderHostInstance = { FlipperRenderHostInstance = {
readTextFromClipboard() { async readTextFromClipboard() {
// TODO: return await navigator.clipboard.readText();
return undefined;
}, },
writeTextToClipboard(_text: string) { writeTextToClipboard(text: string) {
// TODO: return navigator.clipboard.writeText(text);
}, },
async importFile() { async importFile() {
throw new Error('Not implemented'); throw new Error('Not implemented');
@@ -71,7 +70,7 @@ export function initializeRenderHost(
); );
}, },
restartFlipper() { restartFlipper() {
window.flipperShowError!( window.flipperShowError?.(
'Flipper settings have changed, please restart flipper server for the changes to take effect', 'Flipper settings have changed, please restart flipper server for the changes to take effect',
); );
}, },

View File

@@ -197,7 +197,7 @@ function createStubRenderHost(): RenderHost {
return { return {
readTextFromClipboard() { readTextFromClipboard() {
return ''; return Promise.resolve('');
}, },
writeTextToClipboard() {}, writeTextToClipboard() {},
async importFile() { async importFile() {