mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat: expose clipboard apis (#2932)
This commit is contained in:
9
apps/electron/src/main/clipboard/index.ts
Normal file
9
apps/electron/src/main/clipboard/index.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { clipboard, nativeImage } from 'electron';
|
||||||
|
|
||||||
|
import type { NamespaceHandlers } from '../type';
|
||||||
|
|
||||||
|
export const clipboardHandlers = {
|
||||||
|
copyAsPng: async (_, dataURL: string) => {
|
||||||
|
clipboard.writeImage(nativeImage.createFromDataURL(dataURL));
|
||||||
|
},
|
||||||
|
} satisfies NamespaceHandlers;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
|
ClipboardHandlerManager,
|
||||||
DebugHandlerManager,
|
DebugHandlerManager,
|
||||||
ExportHandlerManager,
|
ExportHandlerManager,
|
||||||
UIHandlerManager,
|
UIHandlerManager,
|
||||||
@@ -7,6 +8,7 @@ import type {
|
|||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import { ipcMain } from 'electron';
|
import { ipcMain } from 'electron';
|
||||||
|
|
||||||
|
import { clipboardHandlers } from './clipboard';
|
||||||
import { exportHandlers } from './export';
|
import { exportHandlers } from './export';
|
||||||
import { getLogFilePath, logger, revealLogFile } from './logger';
|
import { getLogFilePath, logger, revealLogFile } from './logger';
|
||||||
import { uiHandlers } from './ui';
|
import { uiHandlers } from './ui';
|
||||||
@@ -26,6 +28,10 @@ type AllHandlers = {
|
|||||||
Electron.IpcMainInvokeEvent,
|
Electron.IpcMainInvokeEvent,
|
||||||
DebugHandlerManager
|
DebugHandlerManager
|
||||||
>;
|
>;
|
||||||
|
clipboard: UnwrapManagerHandlerToServerSide<
|
||||||
|
Electron.IpcMainInvokeEvent,
|
||||||
|
ClipboardHandlerManager
|
||||||
|
>;
|
||||||
export: UnwrapManagerHandlerToServerSide<
|
export: UnwrapManagerHandlerToServerSide<
|
||||||
Electron.IpcMainInvokeEvent,
|
Electron.IpcMainInvokeEvent,
|
||||||
ExportHandlerManager
|
ExportHandlerManager
|
||||||
@@ -44,6 +50,7 @@ type AllHandlers = {
|
|||||||
export const allHandlers = {
|
export const allHandlers = {
|
||||||
debug: debugHandlers,
|
debug: debugHandlers,
|
||||||
ui: uiHandlers,
|
ui: uiHandlers,
|
||||||
|
clipboard: clipboardHandlers,
|
||||||
export: exportHandlers,
|
export: exportHandlers,
|
||||||
updater: updaterHandlers,
|
updater: updaterHandlers,
|
||||||
} satisfies AllHandlers;
|
} satisfies AllHandlers;
|
||||||
|
|||||||
@@ -80,6 +80,15 @@ export abstract class UIHandlerManager extends HandlerManager<
|
|||||||
UIHandlers
|
UIHandlers
|
||||||
> {}
|
> {}
|
||||||
|
|
||||||
|
type ClipboardHandlers = {
|
||||||
|
copyAsPng: (dataURL: string) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export abstract class ClipboardHandlerManager extends HandlerManager<
|
||||||
|
'clipboard',
|
||||||
|
ClipboardHandlers
|
||||||
|
> {}
|
||||||
|
|
||||||
type ExportHandlers = {
|
type ExportHandlers = {
|
||||||
savePDFFileAs: (title: string) => Promise<any>;
|
savePDFFileAs: (title: string) => Promise<any>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user