Skip to content

Commit f6cd029

Browse files
committed
fix(core): add switch button to switch-to-edgeless notification (#8300)
fix AF-1359
1 parent a88e82a commit f6cd029

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/setup-provider.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { notify } from '@affine/component';
21
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
32
import { toggleGeneralAIOnboarding } from '@affine/core/components/affine/ai-onboarding/apis';
43
import { authAtom, openSettingModalAtom } from '@affine/core/components/atoms';
@@ -7,7 +6,6 @@ import {
76
type getCopilotHistoriesQuery,
87
type RequestOptions,
98
} from '@affine/graphql';
10-
import { Trans } from '@affine/i18n';
119
import { track } from '@affine/track';
1210
import { UnauthorizedError } from '@blocksuite/blocks';
1311
import { assertExists } from '@blocksuite/global/utils';
@@ -480,13 +478,5 @@ Could you make a new website based on these notes and send back just the html fi
480478
}));
481479
});
482480

483-
AIProvider.slots.requestRunInEdgeless.on(() => {
484-
notify.warning({
485-
title: (
486-
<Trans i18nKey="com.affine.ai.action.edgeless-only.dialog-title" />
487-
),
488-
});
489-
});
490-
491481
setupTracker();
492482
}

packages/frontend/core/src/desktop/pages/workspace/detail-page/detail-page.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Scrollable, useHasScrollTop } from '@affine/component';
1+
import { notify, Scrollable, useHasScrollTop } from '@affine/component';
22
import { PageDetailSkeleton } from '@affine/component/page-detail-skeleton';
33
import type { ChatPanel } from '@affine/core/blocksuite/presets/ai';
44
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
@@ -9,6 +9,7 @@ import { useDocMetaHelper } from '@affine/core/components/hooks/use-block-suite-
99
import { EditorService } from '@affine/core/modules/editor';
1010
import { RecentDocsService } from '@affine/core/modules/quicksearch';
1111
import { ViewService } from '@affine/core/modules/workbench/services/view';
12+
import { useI18n } from '@affine/i18n';
1213
import { RefNodeSlotsProvider } from '@blocksuite/blocks';
1314
import { DisposableGroup } from '@blocksuite/global/utils';
1415
import { AiIcon, FrameIcon, TocIcon, TodayIcon } from '@blocksuite/icons/rc';
@@ -94,6 +95,8 @@ const DetailPageImpl = memo(function DetailPageImpl() {
9495
// TODO(@eyhn): remove jotai here
9596
const [_, setActiveBlockSuiteEditor] = useActiveBlocksuiteEditor();
9697

98+
const t = useI18n();
99+
97100
useEffect(() => {
98101
if (isActiveView) {
99102
setActiveBlockSuiteEditor(editorContainer);
@@ -187,6 +190,22 @@ const DetailPageImpl = memo(function DetailPageImpl() {
187190
}
188191
}
189192

193+
disposable.add(
194+
AIProvider.slots.requestRunInEdgeless.on(({ host }) => {
195+
if (host === editorHost) {
196+
notify.warning({
197+
title: t['com.affine.ai.action.edgeless-only.dialog-title'](),
198+
action: {
199+
label: t['Switch'](),
200+
onClick: () => {
201+
editor.setMode('edgeless');
202+
},
203+
},
204+
});
205+
}
206+
})
207+
);
208+
190209
editor.setEditorContainer(editorContainer);
191210
const unbind = editor.bindEditorContainer(
192211
editorContainer,
@@ -199,7 +218,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
199218
disposable.dispose();
200219
};
201220
},
202-
[editor, openPage, docCollection.id, jumpToPageBlock]
221+
[editor, openPage, docCollection.id, jumpToPageBlock, t]
203222
);
204223

205224
const [refCallback, hasScrollTop] = useHasScrollTop();

0 commit comments

Comments
 (0)