refactor(editor): add native clipboard extension (#9502)
Closes: [BS-2239](https://linear.app/affine-design/issue/BS-2239/不应该通过window注入affine的api)
This commit is contained in:
@@ -6,6 +6,7 @@ export * from './editor-setting-service';
|
||||
export * from './embed-option-service';
|
||||
export * from './font-loader';
|
||||
export * from './generate-url-service';
|
||||
export * from './native-clipboard-service';
|
||||
export * from './notification-service';
|
||||
export * from './page-viewport-service';
|
||||
export * from './parse-url-service';
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { createIdentifier } from '@blocksuite/global/di';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
/**
|
||||
* Copies the image as PNG in Electron.
|
||||
*/
|
||||
export interface NativeClipboardService {
|
||||
copyAsPNG(arrayBuffer: ArrayBuffer): Promise<boolean>;
|
||||
}
|
||||
|
||||
export const NativeClipboardProvider = createIdentifier<NativeClipboardService>(
|
||||
'NativeClipboardService'
|
||||
);
|
||||
|
||||
export function NativeClipboardExtension(
|
||||
nativeClipboardProvider: NativeClipboardService
|
||||
): ExtensionType {
|
||||
return {
|
||||
setup: di => {
|
||||
di.addImpl(NativeClipboardProvider, nativeClipboardProvider);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user