mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 15:26:59 +08:00
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:
@@ -55,6 +55,7 @@ import {
|
||||
patchEdgelessClipboard,
|
||||
patchEmbedLinkedDocBlockConfig,
|
||||
patchForAttachmentEmbedViews,
|
||||
patchForClipboardInElectron,
|
||||
patchForMobile,
|
||||
patchForSharedPage,
|
||||
patchGenerateDocUrlExtension,
|
||||
@@ -170,6 +171,9 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
|
||||
if (BUILD_CONFIG.isMobileEdition) {
|
||||
patched = patched.concat(patchForMobile());
|
||||
}
|
||||
if (BUILD_CONFIG.isElectron) {
|
||||
patched = patched.concat(patchForClipboardInElectron(framework));
|
||||
}
|
||||
patched = patched.concat(
|
||||
patchDocModeService(docService, docsService, editorService)
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from '@affine/component';
|
||||
import { AIChatBlockSchema } from '@affine/core/blocksuite/blocks';
|
||||
import { WorkspaceServerService } from '@affine/core/modules/cloud';
|
||||
import { DesktopApiService } from '@affine/core/modules/desktop-api';
|
||||
import { type DocService, DocsService } from '@affine/core/modules/doc';
|
||||
import type { EditorService } from '@affine/core/modules/editor';
|
||||
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
||||
@@ -52,6 +53,7 @@ import {
|
||||
EmbedLinkedDocBlockConfigExtension,
|
||||
GenerateDocUrlExtension,
|
||||
MobileSpecsPatches,
|
||||
NativeClipboardExtension,
|
||||
NotificationExtension,
|
||||
ParseDocUrlExtension,
|
||||
PeekViewExtension,
|
||||
@@ -621,3 +623,10 @@ export function patchForAttachmentEmbedViews(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function patchForClipboardInElectron(framework: FrameworkProvider) {
|
||||
const desktopApi = framework.get(DesktopApiService);
|
||||
return NativeClipboardExtension({
|
||||
copyAsPNG: desktopApi.handler.clipboard.copyAsPNG,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user