From afa0e31ecd112285c283e4ed336bff7fb4613265 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Wed, 20 Nov 2024 14:23:18 +0800 Subject: [PATCH] feat(core): open in app cmd (#8870) --- ...se-register-blocksuite-editor-commands.tsx | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx b/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx index 5c73140c53..373c7a73f6 100644 --- a/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx +++ b/packages/frontend/core/src/components/hooks/affine/use-register-blocksuite-editor-commands.tsx @@ -7,14 +7,21 @@ import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; import type { Editor } from '@affine/core/modules/editor'; import { EditorSettingService } from '@affine/core/modules/editor-setting'; import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite'; +import { OpenInAppService } from '@affine/core/modules/open-in-app'; import { WorkspaceFlavour } from '@affine/env/workspace'; import { useI18n } from '@affine/i18n'; import { track } from '@affine/track'; -import { EdgelessIcon, HistoryIcon, PageIcon } from '@blocksuite/icons/rc'; +import { + EdgelessIcon, + HistoryIcon, + LocalWorkspaceIcon, + PageIcon, +} from '@blocksuite/icons/rc'; import { DocService, useLiveData, useService, + useServiceOptional, WorkspaceService, } from '@toeverything/infra'; import { useSetAtom } from 'jotai'; @@ -73,6 +80,8 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) { const isCloudWorkspace = workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD; + const openInAppService = useServiceOptional(OpenInAppService); + useEffect(() => { const unsubs: Array<() => void> = []; const preconditionStrategy = () => @@ -298,6 +307,20 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) { ); } + if (isCloudWorkspace && BUILD_CONFIG.isWeb) { + unsubs.push( + registerAffineCommand({ + id: 'editor:open-in-app', + category: `editor:${mode}`, + icon: , + label: t['com.affine.header.option.open-in-desktop'](), + run() { + openInAppService?.showOpenInAppPage(); + }, + }) + ); + } + unsubs.push( registerAffineCommand({ id: 'alert-ctrl-s', @@ -335,5 +358,6 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) { pageWidth, defaultPageWidth, checked, + openInAppService, ]); }