-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(editor): add native clipboard extension
- Loading branch information
Showing
7 changed files
with
61 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
blocksuite/affine/shared/src/services/native-clipboard-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { ExtensionType } from '@blocksuite/block-std'; | ||
import { createIdentifier } from '@blocksuite/global/di'; | ||
|
||
/** | ||
* Copies the image directly without converting it to png in Electron. | ||
* | ||
* In the web, it can only be converted to png before it can be written to the clipboard, | ||
* or it will throw an exception: `DOMException: Type image/jpeg not supported on write.` | ||
*/ | ||
export interface NativeClipboardService { | ||
copyAsImage(dataURL: string): Promise<boolean>; | ||
} | ||
|
||
export const NativeClipboardProvider = createIdentifier<NativeClipboardService>( | ||
'NativeClipboardService' | ||
); | ||
|
||
export function NativeClipboardExtension( | ||
nativeClipboardProvider: NativeClipboardService | ||
): ExtensionType { | ||
return { | ||
setup: di => { | ||
di.addImpl(NativeClipboardProvider, nativeClipboardProvider); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters