feat(core): open in app cmd (#8870)
This commit is contained in:
@@ -7,14 +7,21 @@ import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
|||||||
import type { Editor } from '@affine/core/modules/editor';
|
import type { Editor } from '@affine/core/modules/editor';
|
||||||
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
import { EditorSettingService } from '@affine/core/modules/editor-setting';
|
||||||
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite';
|
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite';
|
||||||
|
import { OpenInAppService } from '@affine/core/modules/open-in-app';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
import { track } from '@affine/track';
|
import { track } from '@affine/track';
|
||||||
import { EdgelessIcon, HistoryIcon, PageIcon } from '@blocksuite/icons/rc';
|
import {
|
||||||
|
EdgelessIcon,
|
||||||
|
HistoryIcon,
|
||||||
|
LocalWorkspaceIcon,
|
||||||
|
PageIcon,
|
||||||
|
} from '@blocksuite/icons/rc';
|
||||||
import {
|
import {
|
||||||
DocService,
|
DocService,
|
||||||
useLiveData,
|
useLiveData,
|
||||||
useService,
|
useService,
|
||||||
|
useServiceOptional,
|
||||||
WorkspaceService,
|
WorkspaceService,
|
||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
@@ -73,6 +80,8 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) {
|
|||||||
|
|
||||||
const isCloudWorkspace = workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD;
|
const isCloudWorkspace = workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD;
|
||||||
|
|
||||||
|
const openInAppService = useServiceOptional(OpenInAppService);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubs: Array<() => void> = [];
|
const unsubs: Array<() => void> = [];
|
||||||
const preconditionStrategy = () =>
|
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: <LocalWorkspaceIcon />,
|
||||||
|
label: t['com.affine.header.option.open-in-desktop'](),
|
||||||
|
run() {
|
||||||
|
openInAppService?.showOpenInAppPage();
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
unsubs.push(
|
unsubs.push(
|
||||||
registerAffineCommand({
|
registerAffineCommand({
|
||||||
id: 'alert-ctrl-s',
|
id: 'alert-ctrl-s',
|
||||||
@@ -335,5 +358,6 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) {
|
|||||||
pageWidth,
|
pageWidth,
|
||||||
defaultPageWidth,
|
defaultPageWidth,
|
||||||
checked,
|
checked,
|
||||||
|
openInAppService,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user